我想添加spinner/progress bar到左侧的TextView。
________________
| O MY TEXT |
|________________|
O = spinner/progress bar
Run Code Online (Sandbox Code Playgroud)
起初我的想法是添加一个TextView并ProgressBar在它上面添加一个。是否可以在 aTextView本身中做到这一点?如果不是这样做的最佳方法是什么?
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/latlongLocation"
android:layout_width="150dp"
android:layout_height="23dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="21dp"
android:background="@drawable/black"
android:gravity="center"
android:singleLine="true"
android:textColor="#202020"
android:textSize="11sp" />
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
使用框架布局。有了它,您可以像在卡片堆中一样放置视图。
小例子:
<!-- Example of parent -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/black">
<ProgressBar
style="@android:style/Widget.ProgressBar.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="90dp"
android:layout_marginTop="20dp"
android:textSize="32dp"
android:textColor="@android:color/white"
android:text="Test text"/>
</FrameLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
看起来像这样

| 归档时间: |
|
| 查看次数: |
1310 次 |
| 最近记录: |