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'> <TextViewandroid:text='流量配額:'android:layout_gravity='center_vertical'android:layout_weight='3'android:layout_width='0dp'android:layout_height='wrap_content' /> <EditTextandroid: android:layout_weight='4'android:layout_width='0dp'android:layout_height='wrap_content'android:ems='10'android:layout_gravity='center'android:inputType='number' /><Spinnerandroid: android:layout_width='wrap_content'android:layout_height='match_parent' /> </LinearLayout> <DatePicker android: android:layout_width='match_parent' android:layout_height='match_parent' /> <Button android: android:layout_width='match_parent' android:layout_height='match_parent' android:layout_gravity='left' android:text='取消'/><Button android: android:layout_width='match_parent' android:layout_height='match_parent' android:layout_gravity='right' android:text='確定'/> </LinearLayout>
問題解答
回答1:我只能說你那個DatePicker高度都已經match_parent了,還指望著下面的Button能顯示啊!!給你個提示,對DatePicker用weight屬性:
android:layout_weight=1android:layout_width='match_parent'android:layout_height='0dp'
相關文章:
1. mysql - 請問數據庫字段為年月日,傳進的參數為月,怎么查詢那個月所對應的數據2. node.js - win 下 npm install 遇到了如下錯誤 會導致 無法 run dev么?3. javascript - 我的站點貌似被別人克隆了, google 搜索特定文章,除了域名不一樣,其他的都一樣,如何解決?4. 求救一下,用新版的phpstudy,數據庫過段時間會消失是什么情況?5. [python2]local variable referenced before assignment問題6. Python2中code.co_kwonlyargcount的等效寫法7. html - 移動端radio無法選中8. php - 微信開發驗證服務器有效性9. javascript - vue+iview upload傳參失敗 跨域問題后臺已經解決 仍然報403,這是怎么回事啊?10. mysql - 如何在有自增id的情況下,讓其他某些字段能不重復插入
