Java Android微调器的选定文本对齐方式
我正在尝试在Android中对齐微调器的选定文本。它应该与布局中其他TextView和EditText的匹配缩进对齐 布局中的内容: 我想做的是: 我的布局代码:Java Android微调器的选定文本对齐方式,java,android,android-layout,Java,Android,Android Layout,我正在尝试在Android中对齐微调器的选定文本。它应该与布局中其他TextView和EditText的匹配缩进对齐 布局中的内容: 我想做的是: 我的布局代码: <Spinner android:id="@+id/spinner1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignLe
<Spinner
android:id="@+id/spinner1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/TextView01"
android:layout_below="@+id/TextView01"
android:entries="@array/bank_arrays"
android:prompt="@string/bank_prompt"
android:fontFamily="arial,helvetica"
android:hint="@string/bank_prompt"
android:spinnerMode="dialog"
android:ellipsize = "none"/>
请帮助我完成此UI更改
谢谢
更新1:
父布局代码:
<Spinner
android:id="@+id/spinner1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/TextView01"
android:layout_below="@+id/TextView01"
android:entries="@array/bank_arrays"
android:prompt="@string/bank_prompt"
android:fontFamily="arial,helvetica"
android:hint="@string/bank_prompt"
android:spinnerMode="dialog"
android:ellipsize = "none"/>
这是spinnerinflate.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinnertext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#00f5ff"
android:textSize="@dimen/text_size"
android:text="Text Here" >
</TextView>
MyAdapter MyAdapter=新的MyAdapter(此,R.layout.Spinner充气,
arraylist);
spinner.setAdapter(myAdapter)
如果您不需要像下面这样拥有自己的适配器,那么也可以使用SimpleAdapter
ArrayAdapter<String> simpleadapter = new ArrayAdapter<String>(YourActivityName.this, R.layout.spinnerinflate, getResources().getStringArray(R.array.yourarray));
spinner.setAdapter(simpleadapter);
ArrayAdapter simpleadapter=new ArrayAdapter(YourActivityName.this,R.layout.spinnerinflate,getResources().getStringArray(R.array.yourarray));
spinner.setAdapter(simpleadapter);
通过这个充气,你可以做任何你想要的格式化。如果有帮助,请告诉我。这是spinnerinflate.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinnertext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#00f5ff"
android:textSize="@dimen/text_size"
android:text="Text Here" >
</TextView>
MyAdapter MyAdapter=新的MyAdapter(此,R.layout.Spinner充气,
arraylist);
spinner.setAdapter(myAdapter)
如果您不需要像下面这样拥有自己的适配器,那么也可以使用SimpleAdapter
ArrayAdapter<String> simpleadapter = new ArrayAdapter<String>(YourActivityName.this, R.layout.spinnerinflate, getResources().getStringArray(R.array.yourarray));
spinner.setAdapter(simpleadapter);
ArrayAdapter simpleadapter=new ArrayAdapter(YourActivityName.this,R.layout.spinnerinflate,getResources().getStringArray(R.array.yourarray));
spinner.setAdapter(simpleadapter);
通过这个充气,你可以做任何你想要的格式化。如果有帮助,请告诉我。你可以用这行
<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="0dp"
android:textDirection="ltr" />
您可以将填充从左侧增加到更大的空间您可以使用以下行
<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="0dp"
android:textDirection="ltr" />
您可以将填充从左侧增加到更大的空间理想情况下,开始时不应该有任何空间,您可能希望查看定义下拉项的数组。@stack\ved:如果我没有错,这是ICS样式微调器的默认行为。您可以查看以下链接:您可以在微调器android:textAlignment=“viewStart”@stack\u ved下尝试此属性:属性android:textAlignment=“viewStart”对我不起作用。请尝试我在下面发布的答案..肯定会起作用。理想情况下,不应该有任何空间开始,您可能希望查看定义下拉项的数组。@stack\ved:如果我没有错,这是ICS样式微调器的默认行为。您可以检查以下链接:您可以在微调器android:textAlignment=“viewStart”@stack\u ved:属性android:textAlignment=“viewStart”下尝试此属性对我不起作用。请尝试我在下面发布的答案。肯定会起作用。我在api 16上测试了这个,效果很好。你正在测试哪个api级别?我已经在我的设备上用4.2.2(api 17)(果冻豆)测试了这个。这对我不起作用。请帮我解决这个问题。导航填充没有必要,我在adv api 17上进行了测试,并且此代码工作正常。可能在父布局上有问题,您可以将父布局宽度设置为匹配_parent@Sumit:我尝试过-ve填充,但对我也不起作用。@meysam:我已经用父布局xml代码更新了我的问题。让我知道我的父布局是否造成了这个问题。我在api 16上测试了这个问题,工作正常。你在哪个api级别上测试?我已经在我的设备上用4.2.2(api 17)(果冻豆)测试了这个问题。这对我不起作用。请帮我解决这个问题。导航填充没有必要,我在adv api 17上进行了测试,并且此代码工作正常。可能在父布局上有问题,您可以将父布局宽度设置为匹配_parent@Sumit:我尝试过-ve填充,但对我也不起作用。@meysam:我已经用父布局xml代码更新了我的问题。让我知道我的父布局是否造成了此问题。它对我有效,但我无法将其宽度设置为与父布局匹配。但是,我成功地将简单下拉列表转换为“简单微调器”下拉列表。您可以帮助我调整其布局宽度吗?match\u parent不适用于此方法。谢谢对不起,我不能投票,因为我是新来的。你面临的问题是什么?在textView中,只需将android:layout\u width=“fill\u parent”作为您在链接建议中发布的图像就可以了,这对我来说很有效,但我无法将其宽度设置为与\u parent匹配。但是,我成功地将简单下拉列表转换为“简单微调器”下拉列表。您可以帮助我调整其布局宽度吗?match\u parent不适用于此方法。谢谢对不起,我不能投票,因为我是新来的。你面临的问题是什么?在textView中,只需按照链接中发布的图像所示,执行android:layout\u width=“fill\u parent”