Android 对齐自动完成文本视图文本位置
我正在开发一个RTL应用程序,希望我的AutoCompleteTextView小部件从右到左显示文本,但现在它显示在左侧。我试着在我的xml文件中这样做,但是运气不好。谁能帮我一下吗Android 对齐自动完成文本视图文本位置,android,Android,我正在开发一个RTL应用程序,希望我的AutoCompleteTextView小部件从右到左显示文本,但现在它显示在左侧。我试着在我的xml文件中这样做,但是运气不好。谁能帮我一下吗 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" a
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dip"
android:gravity="right">
<TextView
android:id="@+id/cusNameTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/customerName"
android:textColor="#FFFFFF"
android:layout_gravity="right"
/>
<AutoCompleteTextView
android:id="@+id/cusName_CB"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"/>
dropdowntext.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/text_dropDown"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:gravity="right">
</TextView>
final ArrayAdapter<Customer> customerSpinner = new ArrayAdapter<Customer>(MainMenuActivity.this, R.layout.dropdowntextm, customers);
cusName_CB.setAdapter(AutoCompleteAdapter);
最终ArrayAdapter customerSpinner=新的ArrayAdapter(MainMenuActivity.this,R.layout.dropdowntextm、 顾客);
cusName_CB.setAdapter(自动完成适配器);
好的,开始工作。供其他开发人员参考。您需要创建一个文本视图。我已将其保存为dropdowntext.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dropDown"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textColor="@android:color/black"
android:background="@android:color/white"/>
然后在代码中,您需要添加4参数构造函数
ArrayAdapter <Customer> customerSpinner = new ArrayAdapter<Customer>(MainMenuActivity.this, R.layout.dropdowntext,R.id.dropDown, customers);
customerTextView.setAdapter(customerSpinner);
ArrayAdapter customerSpinner=新的ArrayAdapter(mainnuactivity.this,R.layout.dropdowntext,R.id.dropDown,customers);
setAdapter(customerSpinner);
请您帮助我参考我的代码,我会通知您我的ArrayAdapter看起来像最终的ArrayAdapter customerSpinner=new ArrayAdapter(主菜单活动。此,android.R.layout.simple\u spinner\u项目,客户);只需创建一个名为dropdowntText.xml
的新xml文件,并从答案中添加TextView
代码。现在,在构建适配器时,不要使用android.R.layout.simple\u spinner\u item
,而是使用R.layout.dropdowntext
,但我的问题不在于Textview小部件,而在于Autocompletetextview widget。此外,当我尝试使用您的代码时,android:background=“@color/white”android:textColor会出错=“@color/text\u light\u grey”android:textSize=“@dimen/text\u medium”>