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. angular.js使用$resource服務把數據存入mongodb的問題。2. 更新mysql中被別人鎖定的行, 能不能快速失敗直接報錯, 而不是一直等待3. mysql - 記得以前在哪里看過一個估算時間的網站4. python運行后沒有任何反饋要怎么排查5. javascript - h5 video層級太高導致浮在div上面,如何解決?6. mysql刪除一個空數據庫報錯Table storage engine for ’proc’ doe7. javascript - Ajax加載Json時,移動端頁面向左上角縮小一截兒,加載完成后才正常顯示,這該如何解決?8. python小白 想做一個能夠計算圓周率的代碼,不知道怎么寫9. javascript - 如何獲取未來元素的父元素在頁面中所有相同元素中是第幾個?10. javascript - 我的站點貌似被別人克隆了, google 搜索特定文章,除了域名不一樣,其他的都一樣,如何解決?
