1
私はあなたのアンドロイドアプリで次のテンプレートを持っています。 android:layout_MarginTop = "20dip"をうまく使うと、レイアウトの上部に20dipのスペースが表示されます。Android:なぜlayout_marginTopはインクルードタグでのみ動作しますか?
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
style="@style/list_buttom_single"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<LinearLayout android:gravity="center_vertical" android:paddingLeft="10dip" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0">
<TextView android:text="Login/Register" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/title" style="@style/content_page_large_text" />
<TextView android:text="sample text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/subtitle" android:visibility="visible" style="@style/content_page_small_text" />
</LinearLayout>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/itemCount" android:visibility="gone" style="@style/content_page_large_count_text" />
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/chevron" style="@style/list_buttom_chevron" />
</LinearLayout>
ただし、LayoutInflaterを使用してプログラムでこれを実行しようとすると、この20dipのスペースが失われています。
View notesView = mInflater.inflate(R.layout.list_item_single, null);
((TextView) notesView.findViewById(R.id.title)).setText("Notes");
((TextView) notesView.findViewById(R.id.subtitle)).setText("102 notes");
btnContainer.addView(notesView);
私は「同じ」アクション用の2つの異なる動作を取得していますなぜ、唯一の違いは、1つのuisng XMLと他の1は、Javaを使用している含まれていることです。
感謝 T
これは、おかげで、多くの@inazarukをやった! – Thiago