Vit*_*sky 4 xml android textview
我写了一些xml但仍然无法将文本放在屏幕中央作为图像.我想把文字放在我的图像之后.在我的xml上只是试图将文本放在图像下方的中心.我的xml是:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffffff"
android:gravity="fill" >
<ViewFlipper
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:flipInterval="2000" >
<LinearLayout
android:id="@+id/Linear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:baselineAligned="false"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/logonews" />
<TextView
android:id="@+id/textLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/imageLabel"
android:layout_gravity="center"
android:singleLine="true"
android:text="Israel News"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</ViewFlipper>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
Dhe*_*.S. 11
如果CompoundDrawable不符合您的需求,您可以使用RelativeLayout而不是LinearLayout这样:
<RelativeLayout
android:id="@+id/relative"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/logonews" />
<TextView
android:id="@+id/textLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/imageLabel"
android:layout_centerInParent="true"
android:singleLine="true"
android:text="Israel News"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
考虑在顶部使用带有 drawable 的 textview 吗?http://developer.android.com/reference/android/widget/TextView.html#attr_android:drawableTop
在xml中: android:drawableTop
| 归档时间: |
|
| 查看次数: |
29492 次 |
| 最近记录: |