2015-02-23 134 views
1

这里您可以看到我的项目/ groupitems的listview/expandablelistview的结尾。Android Listview/item/textview/shape

有一个背景形状的文本视图。

enter image description here

我想提出TextView的点击。但它太小了......

现在我想跨越形状在整个背景(高度)从上到下

但如何?

<TextView 
    android:id="@+id/ett" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_alignRight="@+id/laptop" 
    android:paddingLeft="5sp" 
    android:paddingRight="5sp" 
    android:paddingTop="1sp" 
    android:paddingBottom="1sp" 
    android:textSize="17sp" 
    android:textStyle="bold" 
    android:textColor="#ffffff" 
    android:text="Set" 
    android:background="@drawable/mbutt_setup" 
    android:focusable="false" 
    /> 
+1

为什么你给填充? – Apurva 2015-02-23 21:26:21

+0

填充应该在'dp'中,而不是'sp'。 – 2015-10-06 17:23:29

回答

1
  1. 要展开一个TextView的可点击区域,您可以使用触摸委托。它在android文档中有很好的解释:http://developer.android.com/training/gestures/viewgroup.html#delegate
  2. 您的textview已经扩展到其父项的整个高度(android:layout_height="match_parent"),这意味着背景不是9patch(http://developer.android.com/tools/help/draw9patch.html)或者textview的父项小于单元格高度。
  3. SP尺寸应该用于文本而不是布局尺寸。考虑更换padding="5sp" with padding="5dp"
0

现在我已将背景从形状更改为正常颜色标签#??????

enter image description here

似乎TextView的是groupitemindex或相对父。布局

?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 


     android:background="@drawable/elv_c_g_line"> 
     <TextView 
     android:id="@+id/laptop" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingLeft="25dp" 
     android:textSize="23dp" 

     /> 

    <TextView 
     android:id="@+id/ett" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_alignRight="@+id/laptop" 
     android:paddingLeft="5sp" 
     android:paddingRight="5sp" 
     android:paddingTop="1sp" 
     android:paddingBottom="1sp" 
     android:textSize="17sp" 
     android:textStyle="bold" 
     android:textColor="#ffffff" 
     android:text="Set" 
     android:background="#33ff33" 
     android:focusable="false" 
     /> 

</RelativeLayout> 

但相对布局已匹配父 - 所以我还没有全空间覆盖 - 背景奥夫groupitem是一个形状太 - 在SP没有9PIC

+0

这是一个答案? – 2015-10-06 17:24:00