Tag: android linelayout

自定义列表视图上的选定项目与上下文操作栏

我最近开始使用android 操作栏和上下文操作栏 (CAB)。 我只有一个活动,这是一个ListActivity。 基本上我使用下面的代码来“激活”CAB: ListView listView = getListView(); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new MultiChoiceModeListener() { @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // Here you can do something when items are selected/de-selected, // such as update the title in the CAB } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { // Respond […]

Android的LinearLayout渐变背景

我无法对LinearLayout应用渐变背景。 这应该是相对简单的,因为我已经阅读,但它似乎并没有工作。 有关参考资料,我正在开发2.1-update1。 header_bg.xml: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:angle="90" android:startColor="#FFFF0000" android:endColor="#FF00FF00" android:type="linear"/> </shape> main_header.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="50dip" android:orientation="horizontal" android:background="@drawable/header_bg"> </LinearLayout> 如果我将@ drawable / header_bg更改为一种颜色 – 例如#FF0000,它可以很好地工作。 我在这里错过了很明显的东西吗

如何添加(垂直)分隔线到水平LinearLayout?

我正在尝试添加一个水平线性布局的分频器,但我无处可去。 分频器只是不显示。 我是Android的新手。 这是我的布局XML: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/llTopBar" android:orientation="horizontal" android:divider="#00ff00" android:dividerPadding="22dip" android:showDividers="middle" > <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:text="asdf" /> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:text="asdf" /> </LinearLayout> </RelativeLayout>

如何使用复合drawable来代替包含ImageView和TextView的LinearLayout

对我的代码运行新的Lint工具。 它提出了很多很好的build议,但是这个我不明白。 这个标签和它的孩子可以用一个和一个复合可绘制来replace 问题:检查当前节点是否可以由使用复合绘图的TextViewreplace。 包含ImageView和TextView的LinearLayout可以更有效地作为复合drawable进行处理 这是我的布局 <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_centerInParent="true"> <ImageView android:id="@+id/upImage" android:layout_width="20dp" android:layout_height="20dp" android:layout_gravity="center_vertical" android:scaleType="centerInside" android:src="@drawable/up_count_big"> </ImageView> <TextView android:id="@+id/LikeCount" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="2dp" android:layout_marginBottom="1dp" android:textColor="@color/gray" android:textSize="16sp" android:layout_gravity="center_vertical"> </TextView> </LinearLayout> 有人可以提供一个具体的例子来说明如何在这种情况下制作一个复合绘制?