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,63 +1,78 @@
<?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_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:singleLine="true"
android:orientation="horizontal"
android:descendantFocusability="blocksDescendants"
android:focusable="false">
<TextView
android:id="@+id/mainUserId"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/label_main_user_id"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
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
android:id="@+id/mainUserIdRest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="&lt;user@example.com>"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_below="@+id/mainUserId"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/mainUserId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_main_user_id"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
style="@android:style/Widget.DeviceDefault.Button.Borderless.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/edit"
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:enabled="true"
android:textColor="@color/black"
android:text="@string/edit" />
<TextView
android:id="@+id/mainUserIdRest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:text="user@example.com"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<TextView
android:id="@+id/revoked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/revoked"
android:textColor="#e00"
android:visibility="visible"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="@android:color/darker_gray" />
</RelativeLayout>
<FrameLayout
android:layout_width="80dp"
android:layout_height="match_parent">
<Button
android:background="@drawable/selector_transparent_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/edit"
android:focusable="false"
android:visibility="visible"
android:enabled="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black"
android:text="@string/edit" />
<TextView
android:id="@+id/revoked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:singleLine="true"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/revoked"
android:textColor="#e00"
android:visibility="visible"
android:layout_gravity="center" />
</FrameLayout>
</LinearLayout>

View File

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

View File

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