如何从Android的大号preVIEW设计让Android列表视图设计

编程入门 行业动态 更新时间:2024-10-11 15:20:42
本文介绍了如何从Android的大号preVIEW设计让Android列表视图设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我让Android大号preVIEW影像风格列表项。 这是我的code,这些类似的设计。

//绘制对象/ list_item_bg.xml

< XML版本=1.0编码=UTF-8&GT?;      <层列表的xmlns:机器人=htt​​p://schemas.android/apk/res/android>           <项目>                 <形状                  机器人:形状=矩形>                   [固体机器人:颜色=#E6E6E6/>                 < /形状>           < /项目>           <项目安卓底=1DP>               <形状                     机器人:形状=矩形>                    [固体机器人:颜色=#FAFAFA/>               < /形状>           < /项目>       < /层列表>

//绘制对象/ list_icon_bg

<形状的xmlns:机器人=htt​​p://schemas.android/apk/res/android     机器人:形状=椭圆形>     [固体机器人:颜色=@色/ list_grey_bg/> < /形状>

//布局/ list_item可

< RelativeLayout的的xmlns:机器人=htt​​p://schemas.android/apk/res/android 机器人:layout_width =match_parent 机器人:layout_height =72dp>     < ImageView的         机器人:ID =@ + ID / list_icon         机器人:layout_width =40dp         机器人:layout_height =40dp         机器人:layout_margin =16DP         机器人:SRC =@可绘制/拇指         机器人:背景=@可绘制/ list_icon_bg/>     <的LinearLayout         机器人:方向=垂直         机器人:layout_width =match_parent         机器人:layout_height =WRAP_CONTENT         机器人:重力=center_vertical         机器人:背景=@可绘制/ list_item_bg         机器人:layout_toRightOf =@ + ID / list_icon         机器人:layout_alignParentRight =真         机器人:layout_alignParentEnd =真         机器人:layout_alignParentTop =真         机器人:layout_alignParentBottom =真正的>         <的TextView             机器人:ID =@ + /标记             机器人:layout_width =FILL_PARENT             机器人:layout_height =WRAP_CONTENT             机器人:文字颜色=@色/ primary_text             机器人:paddingRight =16DP             机器人:文本=示例文本/>     < / LinearLayout中> < / RelativeLayout的>

但我已经为列表项选择状态的问题。列表项选择状态的背景颜色是唯一的图标领域的工作。选定的国家的列表项的背景颜色是不工作的LinearLayout区域。我该如何解决。

解决方案

activity_main: ============ < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android/apk/res/android 机器人:layout_width =match_parent 机器人:layout_height =72dp 机器人:背景=@可绘制/ list_icon_bg>     < ImageView的         机器人:ID =@ + ID / list_icon         机器人:layout_width =40dp         机器人:layout_height =40dp         机器人:layout_margin =16DP         机器人:SRC =@可绘制/拇指         />     <的LinearLayout         机器人:方向=垂直         机器人:layout_width =match_parent         机器人:layout_height =WRAP_CONTENT         机器人:重力=center_vertical         机器人:背景=@可绘制/ list_item_bg         机器人:layout_toRightOf =@ + ID / list_icon         机器人:layout_alignParentRight =真         机器人:layout_alignParentEnd =真         机器人:layout_alignParentTop =真         机器人:layout_alignParentBottom =真正的>         <的TextView             机器人:ID =@ + /标记             机器人:layout_width =FILL_PARENT             机器人:layout_height =WRAP_CONTENT             机器人:文字颜色=@色/ primary_text             机器人:paddingRight =16DP             机器人:文本=示例文本/>     < / LinearLayout中> < / RelativeLayout的>

I make Android L preview image style list item. This is my code for these similar design.

// Drawable/list_item_bg.xml

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="schemas.android/apk/res/android" > <item> <shape android:shape="rectangle"> <solid android:color="#E6E6E6" /> </shape> </item> <item android:bottom="1dp"> <shape android:shape="rectangle"> <solid android:color="#FAFAFA" /> </shape> </item> </layer-list>

//Drawable/list_icon_bg

<shape xmlns:android="schemas.android/apk/res/android" android:shape="oval"> <solid android:color="@color/list_grey_bg" /> </shape>

// Layout/list_item

<RelativeLayout xmlns:android="schemas.android/apk/res/android" android:layout_width="match_parent" android:layout_height="72dp"> <ImageView android:id="@+id/list_icon" android:layout_width="40dp" android:layout_height="40dp" android:layout_margin="16dp" android:src="@drawable/thumb" android:background="@drawable/list_icon_bg"/> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:background="@drawable/list_item_bg" android:layout_toRightOf="@+id/list_icon" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_alignParentTop="true" android:layout_alignParentBottom="true"> <TextView android:id="@+id/label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="@color/primary_text" android:paddingRight="16dp" android:text="Sample Text" /> </LinearLayout> </RelativeLayout>

But i have problem for list item selected state. Background Color of list item selected state is work on icon area only. Selected state's list item background color is not working on LinearLayout area. How can i fix.

解决方案

activity_main: ============ <RelativeLayout xmlns:android="schemas.android/apk/res/android" android:layout_width="match_parent" android:layout_height="72dp" android:background="@drawable/list_icon_bg"> <ImageView android:id="@+id/list_icon" android:layout_width="40dp" android:layout_height="40dp" android:layout_margin="16dp" android:src="@drawable/thumb" /> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:background="@drawable/list_item_bg" android:layout_toRightOf="@+id/list_icon" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_alignParentTop="true" android:layout_alignParentBottom="true"> <TextView android:id="@+id/label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="@color/primary_text" android:paddingRight="16dp" android:text="Sample Text" /> </LinearLayout> </RelativeLayout>

更多推荐

如何从Android的大号preVIEW设计让Android列表视图设计

本文发布于:2023-11-29 14:04:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646601.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大号   视图   列表   Android   preVIEW

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!