Android 微调器在收到项目后向下移动
我有一个简单的布局,下面是一个相关的片段。只要微调器是空的,它看起来就像我想要的那样。一旦我(在运行时)向它添加了项目,它就会像它的一半高度一样往下跳。 为什么?Android 微调器在收到项目后向下移动,android,android-layout,Android,Android Layout,我有一个简单的布局,下面是一个相关的片段。只要微调器是空的,它看起来就像我想要的那样。一旦我(在运行时)向它添加了项目,它就会像它的一半高度一样往下跳。 为什么? 这是“微调器”样式: 填补家长的空缺 @尺寸/按钮高度 @尺寸/微调器\文本 @颜色/按钮 中心垂直 2dp 1. 我不明白为什么,但当我将微调器的填充设置为0dp而不是样式指定的2dp时,问题就消失了。对不起,伙计,我尝试了您的布局和样式。。工作正常。。我无法复制这个问题。。请检查您的片段,当您加载项值时会发生什么情况。@ba
这是“微调器”样式:
填补家长的空缺
@尺寸/按钮高度
@尺寸/微调器\文本
@颜色/按钮
中心垂直
2dp
1.
我不明白为什么,但当我将微调器的填充设置为0dp而不是样式指定的2dp时,问题就消失了。对不起,伙计,我尝试了您的布局和样式。。工作正常。。我无法复制这个问题。。请检查您的片段,当您加载项值时会发生什么情况。@baya:非常感谢您的测试!奇怪的是,当我修补布局的碎片时,这个问题肯定出现了。。。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="10dp" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/lbl"
style="@style/Label.Plain"
android:layout_height="@dimen/button_height"
android:layout_marginRight="5dp"
android:layout_weight="0"
android:gravity="left|center_vertical" />
<Spinner
android:id="@+id/spinner"
style="@style/Spinner"
android:background="#ff0000"
android:layout_width="fill_parent"
android:layout_weight="1" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<style name="Spinner" parent="@android:style/Widget.Holo.Spinner">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">@dimen/button_height</item>
<item name="android:textSize">@dimen/spinner_text</item>
<item name="android:textColor">@color/button</item>
<item name="android:gravity">center_vertical</item>
<item name="android:padding">2dp</item>
<item name="android:maxLines">1</item>
</style>