Improve list item view, borderless button for API < 11

This commit is contained in:
Dominik Schürmann 2014-03-13 20:11:21 +01:00
parent 793d8c266a
commit ba9a4bec3a
4 changed files with 74 additions and 51 deletions

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Borderless Buttons for API < 11, see http://stackoverflow.com/a/14663170 -->
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_shortAnimTime">
<item android:state_pressed="true" android:drawable="@color/emphasis" />
<item android:drawable="@color/transparent" />
</selector>

View File

@ -1,50 +1,63 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight" android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:singleLine="true" android:singleLine="true"
android:orientation="horizontal"
android:descendantFocusability="blocksDescendants" android:descendantFocusability="blocksDescendants"
android:focusable="false"> android:focusable="false">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:focusable="true"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="4dp"
android:paddingTop="4dp"
android:paddingBottom="4dp">
<TextView <TextView
android:id="@+id/mainUserId" android:id="@+id/mainUserId"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/label_main_user_id" android:text="@string/label_main_user_id"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium" />
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView <TextView
android:id="@+id/mainUserIdRest" android:id="@+id/mainUserIdRest"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="&lt;user@example.com>" android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall" android:ellipsize="end"
android:layout_below="@+id/mainUserId" android:text="user@example.com"
android:layout_alignParentLeft="true" android:textAppearance="?android:attr/textAppearanceSmall" />
android:layout_alignParentStart="true" /> </LinearLayout>
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="@android:color/darker_gray" />
<FrameLayout
android:layout_width="80dp"
android:layout_height="match_parent">
<Button <Button
style="@android:style/Widget.DeviceDefault.Button.Borderless.Small" android:background="@drawable/selector_transparent_button"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:id="@+id/edit" android:id="@+id/edit"
android:focusable="false" android:focusable="false"
android:layout_alignTop="@+id/mainUserId"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="false"
android:layout_alignParentTop="false"
android:layout_alignBottom="@+id/mainUserIdRest"
android:visibility="visible" android:visibility="visible"
android:enabled="true" android:enabled="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black" android:textColor="@color/black"
android:text="@string/edit" /> android:text="@string/edit" />
@ -52,12 +65,14 @@
android:id="@+id/revoked" android:id="@+id/revoked"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:singleLine="true"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/revoked" android:text="@string/revoked"
android:textColor="#e00" android:textColor="#e00"
android:visibility="visible" android:visibility="visible"
android:layout_alignParentTop="true" android:layout_gravity="center" />
android:layout_alignParentRight="true" </FrameLayout>
android:layout_alignParentEnd="true" />
</RelativeLayout> </LinearLayout>

View File

@ -33,10 +33,10 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="left" android:layout_gravity="left"
android:ellipsize="end"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:singleLine="true" android:singleLine="true"
android:ellipsize="end"
android:visibility="gone" android:visibility="gone"
android:layout_marginRight="5dip" android:layout_marginRight="5dip"
android:text="" android:text=""

View File

@ -3,5 +3,6 @@
<color name="emphasis">#31b6e7</color> <color name="emphasis">#31b6e7</color>
<color name="bg_gray">#cecbce</color> <color name="bg_gray">#cecbce</color>
<color name="transparent">#00000000</color>
</resources> </resources>