Android 使用“填充父对象”(或“匹配父对象”)作为宽度时的细长微调器
我在微调器中设置android:layout\u width=“fill\u parent”时遇到了一个奇怪的问题: 可单击区域缩小为一条线(红色正方形),只有在这条线上按才能显示微调器的元素: 如果我使用android:layout\u width=“wrap\u content”,我将获得正确的区域: 我想用“填充家长”来做同样的事情 微调器的元素已正确显示。。唯一的问题是单击微调器。 可能的问题是什么Android 使用“填充父对象”(或“匹配父对象”)作为宽度时的细长微调器,android,onclick,spinner,Android,Onclick,Spinner,我在微调器中设置android:layout\u width=“fill\u parent”时遇到了一个奇怪的问题: 可单击区域缩小为一条线(红色正方形),只有在这条线上按才能显示微调器的元素: 如果我使用android:layout\u width=“wrap\u content”,我将获得正确的区域: 我想用“填充家长”来做同样的事情 微调器的元素已正确显示。。唯一的问题是单击微调器。 可能的问题是什么 <LinearLayout xmlns:android="http://s
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#040404"
android:gravity="center"
android:paddingTop="2dp"
android:weightSum="4" >
<TextView
android:id="@+id/mpp_movimento_lbl"
android:background="@drawable/selector_black_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="@drawable/freccia_verde"
android:gravity="center"
android:text="@string/Movimento"
android:textColor="@color/white"
android:textStyle="bold"
android:textSize="17sp" />
<TextView
android:id="@+id/mpp_eccesso_lbl"
android:background="@drawable/selector_black_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="@drawable/freccia_rossa"
android:gravity="center"
android:text="@string/Eccesso"
android:textColor="@color/white"
android:textStyle="bold"
android:textSize="17sp" />
<TextView
android:id="@+id/mpp_fermo_lbl"
android:background="@drawable/selector_black_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="@drawable/freccia_grigia"
android:gravity="center"
android:text="@string/Fermo"
android:textColor="@color/white"
android:textStyle="bold"
android:textSize="17sp" />
<TextView
android:id="@+id/mpp_ripristina_lbl"
android:background="@drawable/selector_black_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="@drawable/ripristina_mappa_40x40"
android:gravity="center"
android:text="@string/Ripristina"
android:textColor="@color/white"
android:textStyle="bold"
android:textSize="17sp" />
</LinearLayout>
<TextView
android:id="@+id/mpp_automezzi_visualizzati_lbl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black"
android:gravity="center"
android:paddingTop="5dp"
android:text="@string/AutomezziVisualizzati"
android:textColor="@color/white"
android:textSize="17sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:paddingTop="5dp" >
<FrameLayout
android:id="@+id/mpp_spinner_frame_fly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/mpp_cerca_btn" >
<Spinner
android:id="@+id/mpp_spinner_spn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textSize="17sp" />
</FrameLayout>
<ImageButton
android:id="@+id/mpp_cerca_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:background="@drawable/selector_white_btn"
android:contentDescription="@string/DescrizioneCerca"
android:gravity="center"
android:onClick="doCerca"
android:src="@drawable/cerca" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#040404"
android:gravity="center" >
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="@+id/mpp_mappa_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
尝试将微调器的父项高度设置为与父项匹配。你真的需要这样的布局吗?无需在FrameLayout中放置微调器,请尝试将微调器的权重设置为1,并将RelativeLayout替换为LinearLayout是否可以发布布局文件?是的,FrameLayout没有用处(我尝试使用它仅用于解决问题)。如果我使用宽度=fill\u parent或权重=1的LinearLayout和微调器,我看不到右边的ImageButton。好吧,我建议你用LinearLayout替换RelativeLayouth,然后将微调器的权重设置为1,宽度设置为0dpOk,我尝试删除FrameLayout并使用,但问题仍然很奇怪,您是否使用android SDK中的HierarchyViewer观察了视图层次结构(它包含在监视工具中,可以连接到emulator或根设备)?它是如此薄还是因为某些视图覆盖了它?我不能使用HV,因为我没有供开发人员使用的设备,本指南中建议的项目“ViewServer”给了我一些错误