[英]ImageButton not showing to right of TextView in RelativeLayout
[英]TextView not showing after ImageButton
我想有一個圖像按鈕,在圖像按鈕下面,我想要文本視圖。 我認為我做對了所有事情,但只是沒有出現。 有任何想法嗎?
這是代碼:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#A9F5E1"
android:orientation="vertical">
<TableRow android:padding="5dp"
android:paddingBottom="10dp">
<ImageButton android:layout_height="150dp"
android:layout_width="400dp"
android:src="@drawable/flood_sign"
android:background="@android:color/transparent"
android:id="@+id/enterPreventiva"/>
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="@string/preventiva"
android:textColor="#FFFFFF"/>
</TableRow>
</TableLayout>
添加新行並將其放置在此處。
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#A9F5E1"
android:orientation="vertical">
<TableRow android:padding="5dp"
android:paddingBottom="10dp">
<ImageButton android:layout_height="150dp"
android:layout_width="400dp"
android:src="@drawable/flood_sign"
android:background="@android:color/transparent"
android:id="@+id/enterPreventiva"/>
</TableRow>
<TableRow android:padding="5dp"
android:paddingBottom="10dp">
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="@string/preventiva"
android:textColor="#FFFFFF"/>
</TableRow>
</TableLayout>
在此使用框架布局。 它將在按鈕上覆蓋文本
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageButton android:layout_height="150dp"
android:layout_width="400dp"
android:src="@drawable/flood_sign"
android:background="@android:color/transparent"
android:id="@+id/enterPreventiva">
</ImageButton>
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="@string/preventiva"
android:textColor="#FFFFFF">
</TextView>
</FrameLayout>
您需要重新使用ImageButton的寬度
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#A9F5E1"
android:orientation="vertical">
<TableRow android:padding="5dp"
android:paddingBottom="10dp">
<ImageButton android:layout_height="150dp"
android:layout_width="200dp"
android:src="@drawable/ic_launcher"
android:background="@android:color/transparent"
android:id="@+id/enterPreventiva"/>
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="pratik"
android:textColor="#FFFFFF"/>
</TableRow>
否則,您可以在新行中使用此文本
您可以這樣操作:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#A9F5E1"
android:orientation="vertical">
<TableRow android:padding="5dp"
android:paddingBottom="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageButton
android:id="@+id/enterPreventiva"
android:layout_width="400dp"
android:layout_height="150dp"
android:background="@android:color/transparent"
android:src="@drawable/ic_launcher" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="tes"
android:textColor="#000000"
android:textSize="50dp" />
</LinearLayout>
</TableRow>
</TableLayout>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.