android - 安卓布局问题
PHP中文网
PHP中文网 2017-04-18 09:14:02
[Android讨论组]

我希望一个dialog里面显示一个datePicker和两个按钮,但是显示不出按钮,另外流量配额那个TextView也有点问题,调了好多次也没弄明白,我希望他显示在一行并且竖直居中,下面是显示效果和布局文件,麻烦大家帮忙改改,谢谢

    <?xml version="1.0" encoding="utf-8"?>
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="wrap_content"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <TextView
                android:text="流量配额:"
                android:layout_gravity="center_vertical"
                android:layout_weight="3"
                android:layout_width="0dp"
                android:layout_height="wrap_content" />
    
    
            <EditText
                android:id="@+id/editText"
    
                android:layout_weight="4"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:ems="10"
                android:layout_gravity="center"
                android:inputType="number" />
    
            <Spinner
                android:id="@+id/spinner_datFormat"
                android:layout_width="wrap_content"
                android:layout_height="match_parent" />
    
        </LinearLayout>
    
    
    
        <DatePicker
            android:id="@+id/datePicker"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    
        <Button
            android:id="@+id/button_confirmTimeCancel"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="left"
            android:text="取消"/>
        <Button
            android:id="@+id/button_confirmTime"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:text="确定"/>
    </LinearLayout>
PHP中文网
PHP中文网

认证高级PHP讲师

全部回复(1)
PHP中文网

我只能说你那个DatePicker高度都已经match_parent了,还指望着下面的Button能显示啊!!
给你个提示,对DatePicker用weight属性:

android:layout_weight=1
android:layout_width="match_parent"
android:layout_height="0dp"
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

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