首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >android按钮布局未显示

android按钮布局未显示
EN

Stack Overflow用户
提问于 2013-01-02 19:16:40
回答 6查看 88关注 0票数 0

嘿,我正在做一个安卓应用程序,有人能告诉我为什么我的andriod屏幕上没有显示按钮mi_perfil吗?这是我的布局代码:

代码语言:javascript
运行
复制
<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>

我想把按钮放在屏幕的右边,但它没有出现。

谢谢。

EN

回答 6

Stack Overflow用户

发布于 2013-01-02 19:41:10

使用RelativeLayout而不是外部LinearLayout。

然后,您可以将图像视图安排在左侧,将按钮安排在右侧。

票数 1
EN

Stack Overflow用户

发布于 2013-01-02 19:49:18

如果你使用RelativeLayout,你可以使用按钮android:layout_alignParentRight="true"中的属性来纠正你的按钮。

票数 0
EN

Stack Overflow用户

发布于 2013-01-02 19:50:48

请在子linearLayout中尝试此按钮代码

代码语言:javascript
运行
复制
<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>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14121080

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档