簡體   English   中英

Android微調器的選定文本對齊方式

[英]Selected text alignment for Android spinner

我正在嘗試對齊Android中微調框的選定文本。 它應與布局中其他TextView和EditText的匹配縮進對齊。

我的布局中有什么:

http://i.imgur.com/Y5sgbsN.png

我想做的事:

http://i.imgur.com/viVHpiC.png

我的布局代碼:

 <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: 父級布局代碼:

<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"
    android:layout_marginBottom="14.5sp"
    android:layout_marginLeft="14.5sp"
    android:layout_marginRight="14.5sp"
    android:layout_marginTop="14.5sp"
    tools:context=".RegistrationActivity" >

這是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>

In your code you can set the custom Layout for spinner as 

MyAdapter myAdapter =新的MyAdapter(this,R.layout.spinnerinflate,arraylist); spinner.setAdapter(myAdapter);


如果不需要以下適配器,也可以使用SimpleAdapter

ArrayAdapter<String> simpleadapter = new ArrayAdapter<String>(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" />

您可以從左到右增加填充空間

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM