首页 > 移动平台 > 详细

从零开始学android-一行两个按钮居中 布局

时间:2015-02-11 15:54:57      阅读:386      评论:0      收藏:0      [点我收藏+]

方法一:

<RelativeLayout android:id="@+id/relativeTop" 
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        >
        
       <Button  
               android:id="@+id/btnGetMp3s"
            android:text="@string/strGetMp3List"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:gravity="center"
            android:layout_toLeftOf="@id/txtHide"
               />
       <TextView android:id="@+id/txtHide" android:layout_width="25" android:layout_height="1"
           android:layout_centerHorizontal="true" />
       <Button  
               android:id="@+id/btnExitSys"
            android:text="@string/strExitSys"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_toRightOf="@id/txtHide"
            
               />
    </RelativeLayout>

方法二:

<LinearLayout android:layout_width="fill_parent"

                android:layout_height="wrap_content"

                android:orientation="horizontal"

                style="@android:style/ButtonBar"

                >

                <Button android:id="@+id/btn_listview"

                    android:layout_height="wrap_content"

                    android:layout_width="0dp"

                    android:layout_weight="1"

                    android:text="ListView"/>

                <Button android:id="@+id/btn_emptyview"

                    android:layout_height="wrap_content"

                    android:layout_width="0dp"

                    android:layout_weight="1"

                    android:text="EmptyView"/>      

            </LinearLayout>

 

从零开始学android-一行两个按钮居中 布局

原文:http://www.cnblogs.com/dekevin/p/4286160.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!