Home | History | Annotate | Download | only in layout
      1 <!--
      2   Copyright 2013 The Android Open Source Project
      3 
      4   Licensed under the Apache License, Version 2.0 (the "License");
      5   you may not use this file except in compliance with the License.
      6   You may obtain a copy of the License at
      7 
      8       http://www.apache.org/licenses/LICENSE-2.0
      9 
     10   Unless required by applicable law or agreed to in writing, software
     11   distributed under the License is distributed on an "AS IS" BASIS,
     12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13   See the License for the specific language governing permissions and
     14   limitations under the License.
     15   -->
     16 
     17 <!--
     18     For list items that contain secondary actions (in this case, 'delete'),
     19     it's important to use dividers to distinguish the primary touch target from
     20     the secondary action. This is done using android:showDividers and its
     21     related attributes.
     22 
     23     The android:dividerPadding attribute insets the divider line by the given
     24     amount on each side (in this case, top and bottom). Divider padding helps
     25     establish visual hierarchy when several dividers are used in a screen. In
     26     this case, the padding helps separate this vertical divider from horizontal
     27     list item separators in the main ListView, and establishes a stronger
     28     relationship between the delete action and the primary target to its left.
     29 -->
     30 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     31     android:orientation="horizontal"
     32     android:layout_width="match_parent"
     33     android:layout_height="wrap_content"
     34     android:minHeight="?android:listPreferredItemHeight"
     35     android:divider="?android:dividerVertical"
     36     android:dividerPadding="8dp"
     37     android:showDividers="middle">
     38 
     39     <!--
     40         Any view or view group can become interactive by simply setting the
     41         android:clickable and android:focusable attributes to true.
     42 
     43         When doing this, make sure to provide adequate touch feedback by also
     44         setting the view background to ?android:selectableItemBackground. When
     45         using the Holo theme, this drawable is transparent by default, but
     46         changes to a translucent color overlay when the view is pressed or
     47         focused.
     48     -->
     49     <LinearLayout android:id="@+id/primary_target"
     50         android:layout_width="0dp"
     51         android:layout_height="match_parent"
     52         android:layout_weight="1"
     53         android:orientation="vertical"
     54         android:paddingLeft="?android:listPreferredItemPaddingLeft"
     55         android:paddingRight="?android:listPreferredItemPaddingRight"
     56         android:clickable="true"
     57         android:focusable="true"
     58         android:gravity="center_vertical"
     59         android:background="?android:selectableItemBackground">
     60 
     61         <TextView style="?android:textAppearanceListItemSmall"
     62             android:id="@android:id/text1"
     63             android:layout_width="wrap_content"
     64             android:layout_height="wrap_content"
     65             android:text="@string/dummy_title" />
     66 
     67         <TextView style="?android:textAppearanceSmall"
     68             android:id="@android:id/text2"
     69             android:layout_width="wrap_content"
     70             android:layout_height="wrap_content"
     71             android:text="@string/dummy_subtitle" />
     72 
     73     </LinearLayout>
     74 
     75     <!--
     76         When using the Holo theme, setting a Button or ImageButton to
     77         ?android:borderlessButtonStyle removes its border and sets the
     78         background to ?android:selectableItemBackground, as described above.
     79     -->
     80     <ImageButton android:id="@+id/secondary_action"
     81         style="?android:borderlessButtonStyle"
     82         android:layout_width="@dimen/standard_touch_target_size"
     83         android:layout_height="match_parent"
     84         android:src="@drawable/ic_action_delete"
     85         android:contentDescription="@string/delete_content_description" />
     86 
     87 </LinearLayout>
     88