我有三個編輯文本字段,並在我的創造(我會隱藏第二和第三編輯文本),我想顯示在中心第一編輯文本,如果第一次編輯的文本是有效的,那麼我聯合國將隱藏的第二個編輯的文字,現在我要對齊第一編輯文本和第二編輯文本應該在佈局居中....等等反之亦然佈局中心的所有元素自動
回答
android:gravity="center"
使用此父佈局居中元素
OR
您可以使用
android:layout_gravity="center"
在元件
在其父中心。
而對於隱藏的EditText,請使用
android:visibility="gone"
,這樣它沒有考慮空間佈局
其工作tqqq bro –
請將答案標記爲已接受或正確 –
嘗試這種佈局`
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="first edit text"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="second edit text"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="second edit text"/>
</LinearLayout>
</RelativeLayout>`
,然後隱藏您想隱藏在java代碼中的編輯文本
其工作tqqq bro –
您可以檢查標記是否正常工作 –
- 1. 爲所有設備自動佈局UIImage
- 2. Magento2:使用XML佈局移動現有元素內的元素
- 3. 將樣式設置爲佈局中的所有TextView元素
- 4. 擺動流佈局中斷元素
- 5. 在活動中獲取佈局元素
- 6. 在QML佈局中的元素上自動換行
- 7. 本地腳本中絕對佈局中心的位置元素
- 8. 3列布局中的CSS中心元素
- 9. 訪問從主要佈局包括佈局的所有子元素
- 10. 如何對齊父代中心的所有左浮動元素?
- 11. 自動佈局:Xcode 6:居中UI元素
- 12. Android ViewPager不顯示我的所有佈局元素
- 13. 自動佈局製作相同的寬度爲每個元素
- 14. C#WPF彈出式佈局=中心和元素頂部
- 15. 如何將中心wj-popup與所有者元素中心
- 16. Android佈局:組動態元素
- 17. 動態訪問佈局元素
- 18. 具有自動佈局的動態uiview佈局
- 19. 中心故事板在自動佈局中的看法
- 20. 中心佈局Android
- 21. 佈局元素沒有出現
- 22. 中心浮動元素
- 23. 中心2浮動元素
- 24. 使用自動佈局正確對齊通知中心小部件中的元素
- 25. 自動佈局把uiview放在兩個uiview的中心
- 26. 自動佈局阻止我改變視圖的中心
- 27. 沒有浮動元素的雙列布局?
- 28. 的Xcode自動佈局不工作的所有iPhone屏幕
- 29. 在android中佈局的隱形元素
- 30. 佈局問題中的ng-switch元素
in我的創建方法 –
分享您的佈局xml文件 – Piyush