А у меня другой вопрос.
Есть Android 2.3.3 в котором диалог фрагмент отображается так, как я хочу -
http://prntscr.com/296xvr
Но при запуске на Android 4 ситуация уже другая -
http://prntscr.com/296y99
Layout для фрагмента такой:
[syntax=xml]
<TableLayout xmlns:android="
http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="200dp"
android:layout_height="wrap_content" android:baselineAligned="false"
android:measureWithLargestChild="false" android:showDividers="middle" android:clickable="true"
android:divider="@drawable/line">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="center_vertical|left"
android:clickable="true" android:onClick="onClick" android:id="@+id/trVolume">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView" android:src="@drawable/volume" android:contentDescription="s"
android:layout_marginTop="5dp" android:layout_marginBottom="5dp" android:layout_marginLeft="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView" android:text="@string/lblVolume" android:paddingLeft="20dp"
android:layout_marginRight="10dp"/>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="center_vertical" android:clickable="true"
android:id="@+id/trLength">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView2" android:src="@drawable/length" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginLeft="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lblLength"
android:id="@+id/textView2" android:paddingLeft="20dp" android:layout_marginRight="10dp"/>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="center_vertical|left" android:clickable="true"
android:id="@+id/trWeight">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView3" android:src="@drawable/weight" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginLeft="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lblWeight"
android:id="@+id/textView3" android:paddingLeft="20dp" android:layout_marginRight="10dp"/>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="center_vertical|left" android:clickable="true"
android:id="@+id/trArea">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView4" android:src="@drawable/area" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginLeft="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lblArea"
android:id="@+id/textView4" android:paddingLeft="20dp" android:layout_marginRight="10dp"/>
</TableRow>
</TableLayout>
[/syntax]
Создается фрагмент таким способом
[syntax=java]
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
getDialog().setTitle(getString(R.string.selectConv));
View v = inflater.inflate(R.layout.unit_conv_select, null);
return v;
}
[/syntax]
Внимание вопрос - как заставить android 4 выставлять ширину диалога по ширине содержимого, а не растягивать его на весь экран?