My tidy narrow spinner expands to the ugly plain screen, when activated (continued)
As I am now allowed to post images, so I accomplish my question by images and code.
My 5 spinners, as seen on the first screenshot, represent only short numbers. There is no problem to form their width in .xml file. But when they are activated, they expands to into a full width of the screen, making it´s appearance ugly, as seen in the second screenshot. I use the standard code from the SDK tutorial to populate the spinners. I experimented with simple_spinner_dropdown_item and simple_spinner_item. Both have the same functionality, but slightly different graphics. Unfortunately, I found nowhere published how to acces/modify these 2 blocks, so I cannot change their width, color, textsize, atc. Is here somebody having some hints how to cope with this problem? This is a standard code of spinner (=SDK tutorial), (only one spinner is showed):
Spinner s1_weight = (Spinner)findViewById(R.id.s1_weight);//Reference to "s1_weight" in main.xml, registered in R.id.
ArrayAdapter<CharSequence> adapter_weight = ArrayAdapter.createFromResource(
this, R.array.Weight_array_id, android.R.layout.simple_spinner_item);
adapter_weight.setDropDownViewResource(android.R.layout.simple_spinner_item);
s1_weight.setAdapter(adapter_weight);
s1_weight.setOnItemSelectedListener(new OnItemSelectedListener() { //Register a callback to be invoked when an item in this AdapterView has been selected.
public void onItemSelected(AdapterView<?> arg0, View arg1, //Callback method to be invoked when an item in this view has been selected
int arg2, long arg3) {
myCalc();}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
This is my .xml file (only one spinner is showed):
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:text="@string/txtWeight"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight=".6"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold">
</TextView>
<Spinner
android:entries="@array/Weight_array_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight开发者_运维百科="1"
android:id="@+id/s1_weight">
</Spinner>
</LinearLayout>
And these are my screenshots:
精彩评论