android - 安卓ui设计底部固定问题
黄舟
黄舟 2017-04-17 11:59:49
[Android讨论组]

在安卓的UI设计里面碰到一个问题,当底部的两个按钮用layout_alignParentBottom时,并不会固定在底部,上面的EditText会覆盖在下面,实际如图所示:

事实上我要的是这个效果(注:EditText高度写的是固定高度)

代码如下:






    

   





    

    







    





        

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

全部回复(1)
怪我咯

Android在解析布局文件的时候是从上往下的。所以你要先放底部的两个Button,再放中间的EditText,并且设置EditText的上下相对位置.

<LinearLayout
        android:id="@+id/layout_business_btn"
        style="@style/sell_layout_btn_background"
        android:layout_below="@+id/layout_business_detail" 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" 
        android:layout_alignParentBottom="true">

        <Button 
                android:id="@+id/btn_business_clear"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:layout_marginRight="5dp"
                android:background="@drawable/main_login_selector"              
                android:textColor="@color/login_txt_selector" 
                android:text="@string/business_clear"
                style="?android:attr/buttonBarButtonStyle"/>

         <Button 
                android:id="@+id/btn_business_save"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:layout_marginLeft="5dp"
                android:background="@drawable/main_login_selector"              
                android:textColor="@color/login_txt_selector"                    
                android:text="@string/business_save"
                style="?android:attr/buttonBarButtonStyle"/>   
</LinearLayout> 

<LinearLayout
    android:id="@+id/layout_business_detail"
    style="@style/sell_layout_btn_background"
    android:layout_height="match_parent"
    android:layout_below="@+id/layout_business_typedetail"
    android:layout_above="@id/layout_business_btn">

    <EditText
        android:id="@+id/txt_business_detail"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="top"
        android:inputType="textMultiLine" 
        android:hint="@string/business_detailHint"
        />
</LinearLayout>
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号