嘿,我正在做一个安卓应用程序,有人能告诉我为什么我的andriod屏幕上没有显示按钮mi_perfil吗?这是我的布局代码:
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
>
<ImageView
android:id="@+id/foto"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginRight="6dip"
android:layout_marginLeft="20dip" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout2"
android:gravity="center_horizontal"
android:layout_toRightOf="@id/linearLayout"
android:orientation="vertical" >
<TextView
android:id="@+id/txt3"
android:layout_width="match_parent"
android:layout_height="34dp"
/>
<TextView
android:id="@+id/txt4"
android:layout_width="match_parent"
android:layout_height="34dp"
/>
<TextView
android:id="@+id/txt2"
android:layout_width="match_parent"
android:layout_height="34dp"
android:text="@string/Importar_Contactos" />
</LinearLayout>
<Button android:id="@+id/miPerfil"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:text="@string/boton_mi_perfil"
android:onClick="MiPerfil"
android:layout_marginRight="20dip"
android:layout_marginLeft="6dip" />
</LinearLayout>我想把按钮放在屏幕的右边,但它没有出现。
谢谢。
发布于 2013-01-02 19:41:10
使用RelativeLayout而不是外部LinearLayout。
然后,您可以将图像视图安排在左侧,将按钮安排在右侧。
发布于 2013-01-02 19:49:18
如果你使用RelativeLayout,你可以使用按钮android:layout_alignParentRight="true"中的属性来纠正你的按钮。
发布于 2013-01-02 19:50:48
请在子linearLayout中尝试此按钮代码
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
>
<ImageView
android:id="@+id/foto"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginRight="6dip"
android:layout_marginLeft="20dip" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout2"
android:gravity="center_horizontal"
android:layout_toRightOf="@id/linearLayout"
android:orientation="vertical" >
<TextView
android:id="@+id/txt3"
android:layout_width="match_parent"
android:layout_height="34dp"
/>
<TextView
android:id="@+id/txt4"
android:layout_width="match_parent"
android:layout_height="34dp"
/>
<TextView
android:id="@+id/txt2"
android:layout_width="match_parent"
android:layout_height="34dp"
android:text="@string/Importar_Contactos" />
<Button android:id="@+id/miPerfil"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:text="@string/boton_mi_perfil"
android:onClick="MiPerfil"
android:layout_marginRight="20dip"
android:layout_marginLeft="6dip" />
</LinearLayout>
https://stackoverflow.com/questions/14121080
复制相似问题