我在XML文件,宽度和高度设置为wrap_content和我背景设置为旋转器旋转器,对齐微调文本设置背景当微调
文本被显示在中心如果我在DP或FILL_PARENT设置宽度,则文本左对齐显示,但我要左对齐时微调宽度WRAP_CONTENT
我在XML文件,宽度和高度设置为wrap_content和我背景设置为旋转器旋转器,对齐微调文本设置背景当微调
文本被显示在中心如果我在DP或FILL_PARENT设置宽度,则文本左对齐显示,但我要左对齐时微调宽度WRAP_CONTENT
您可以使用像这样的 设置你的微调观点:
res/layout/my_spinner_textview.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/spinnerItemStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center" />
public class HelloSpinner extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.planets_array,
// android.R.layout.simple_spinner_item);
R.layout.my_spinner_textview);
// adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
adapter.setDropDownViewResource(R.layout.my_spinner_textview);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
}
//No other modification needed.
我不想在文本中心... – Jayesh
在您的自定义文本视图中包含这四行以使您的微调器文本左对齐。
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
您可能想要附加9修补程序文件和布局。 –
请发布您的xml文件 –