請幫助我 - 我是新的android應用程序。
我想要設計這種類型的邊框。如何設計這種類型的邊框在android
的設計是:
地告訴我哪佈局和查看我應該使用(GridView控件,相對或線性)。
還可以幫我選擇顏色應該改變的任何框。
請幫助我 - 我是新的android應用程序。
我想要設計這種類型的邊框。如何設計這種類型的邊框在android
的設計是:
地告訴我哪佈局和查看我應該使用(GridView控件,相對或線性)。
還可以幫我選擇顏色應該改變的任何框。
您可以使用GridView控件這個
<GridView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="2"
android:background="@drawable/selector" >
</GridView>
設置android:numColumns
您number.And作爲bacground添加到選擇你的GridView
這看起來像一個GridView
對於這種類型的邊界的要求你需要一個形狀:
你需要在你的可繪製文件夾中創建2個形狀和一個選擇器:
1)對於正常的狀態(未加壓的)
2)爲您的按壓狀態
3)你的最終形狀,其將被用作背景,用於的GridItem
1)grid_item_shape
/*This will looke like your border without the textview
(you can make the textview color blue from your adapter or your layout file) */
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@color/grid_view_color"/>
<stroke android:width="1dp" android:color="#001414"/>
</shape>
2)grid_item_shape_pressed
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ffc392"/>
<stroke android:width="2dp" android:color="#001414"/> //choose your own color here
</shape>
3)grid_item_background
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/grid_item_shape"
android:state_pressed="false">
</item>
<item android:drawable="@drawable/grid_item_shape_pressed"
android:state_pressed="true">
</item>
</selector>
如果塊(框的大小)是可變的,那麼你可以選擇GridView
其他
去嵌套在一些視圖(TextViews或按鈕) LinearLayout
對於選擇顏色可以添加一個選擇器至可繪製文件夾參考Selector Example