我想創建一個如下圖所示的視圖。我的實現有一些linearLayouts。一個帶有自定義drawable的根可以獲得圓角邊緣,然後使用其他兩個文本視圖和視圖分隔線。有沒有更快,更簡單的方法來做到這一點?如何使用圓角和兩個文字視圖創建自定義視圖?
0
A
回答
1
0
我沒有太多時間,只是試圖給一個快速的樣本。這是我對你的問題代碼:
your_main_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/your_bg.xml">
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="my text" />
<View
android:id="@+id/seperator
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/tv1" />
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2nd text here"
android:layout_below="@+id/seperator" />
</RelativeLayout>
your_bg.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="5dp"
/>
<solid android:color="#fff" />
<stroke android:color="#000" />
</shape>
相關問題
- 1. 如何使用兩個文本視圖創建自定義網格視圖
- 2. 如何使用多個圖像創建圓角視圖
- 3. 創建一個圓角視圖
- 4. 創建自定義視圖
- 5. 創建自定義視圖
- 6. 創建自定義視圖
- 7. 創建自定義視圖?
- 8. 創建自定義視圖
- 9. 如何在一個視圖控制器中使用兩個自定義UITableViewCells創建兩個表視圖?
- 10. 如何創建像自定義列表視圖的自定義圖像視圖?
- 11. 如何使用textview和edittext創建自定義視圖?
- 12. 如何在Android的自定義視圖中創建自定義視圖?
- 13. 創建一個自定義視圖組
- 14. 在Android中使用圓角的自定義視圖
- 15. 如何創建自定義圖庫視圖和縮放?
- 16. 如何創建下拉表格視圖使用兩個自定義單元格?
- 17. Android:具有自定義視圖和圓角的AlertDialog
- 18. 如何在Android中創建圓角地圖視圖?
- 19. Android - 如何創建一個帶圓角和平鋪圖像背景的視圖?
- 20. 使用自定義圖像的圓角
- 21. 如何使用自定義視圖創建彈出式菜單?
- 22. 如何使用swift創建自定義彈出視圖?
- 23. 把手創建自定義圓形視圖
- 24. 如何使用自定義列表視圖創建自定義對話框
- 25. Android地圖:在onDraw()中使用文本和按鈕創建自定義視圖
- 26. 使用兩個模型創建視圖
- 27. 自定義創建的視圖
- 28. 在視圖內創建自定義tableviewcell
- 29. 創建自定義視圖時出錯
- 30. 創建自定義列表視圖
你可以做到這一點通過自定義'@android:風格/ Theme.Dialog' – silentw
@silentw你是說在LinearLayout上使用它? – irobotxxx
不,在活動清單上... – silentw