This is the design effect.
I tried to use the LinearLayout
to implement it like this:
<LinearLayout
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
<TextView
android:text="Type"
android:background="@drawable/poi_nearby_cell"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_weight="1"/>
<LinearLayout
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1">
<TextView
android:text="Type1"
android:background="@drawable/poi_nearby_cell"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
<TextView
android:text="Type2"
android:background="@drawable/poi_nearby_cell"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1">
<TextView
android:text="Type3"
android:background="@drawable/poi_nearby_cell"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
<TextView
android:text="Type4"
android:background="@drawable/poi_nearby_cell"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
And the poi_nearby_cell
:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@android:color/transparent">
</solid>
<stroke
android:width="0.5dp"
android:color="#A0A0A0">
</stroke>
</shape>
This is what I got now.
However I meet many problems:
1 I use the drawable/poi_nearby_cell
to create the border for the textview.
However I have also to implement the cell press effect like the "Type1" in the design effect picture. Generally I set axml drawable resource as the background like this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<color android:color="#ffebf6ff"/>
</item>
<item>
<color android:color="#fffefefe"/>
</item>
</selector>
However in my case, I cannot set a view with two background at the same time. Any alternative?
2 As you can see, the border have different width value. Normally I want the border to be 1dp
however, in my example, the border between two cell maybe 2dp
.
I have no idea to continue. Any suggestions?