Android 删除布局xml文件中的重复
我有两个布局(~80行),它们之间只有几个文本值不同。我可以通过xml删除这样的重复吗?或者我只能通过每次设置不同的字符串资源以编程方式来实现 简单的例子: 第一个xml:Android 删除布局xml文件中的重复,android,android-layout,android-resources,duplicate-removal,Android,Android Layout,Android Resources,Duplicate Removal,我有两个布局(~80行),它们之间只有几个文本值不同。我可以通过xml删除这样的重复吗?或者我只能通过每次设置不同的字符串资源以编程方式来实现 简单的例子: 第一个xml: 第二个xml: 它们仅在文本值上有所不同:@string/title\u 1vs@string/title\u 2,以及,@string/details\u 1vs@string/details\u 2 对不起,我的英语是请使用相同的布局-在充气后提供文本视图id并设置字符串你能详细说明你的问题吗?我认为“可以通
第二个xml:
它们仅在文本值上有所不同:@string/title\u 1
vs@string/title\u 2
,以及,@string/details\u 1
vs@string/details\u 2
对不起,我的英语是请使用相同的布局-在充气后提供文本视图id并设置字符串你能详细说明你的问题吗?我认为“可以通过编程实现”将是更好的选择。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/background"
android:orientation="vertical"
android:paddingTop="@dimen/padding_top"
android:paddingBottom="@dimen/padding_bottom"
android:paddingLeft="@dimen/padding_left"
android:paddingRight="@dimen/padding_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/image"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<View
android:layout_height="@dimen/space_between_image_and_text"
android:layout_width="1dp" />
<TextView
android:text="@string/title_1"
android:textStyle="bold"
android:textColor="@color/text_color_title"
android:singleLine="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="@string/details_1"
android:textColor="@color/text_color_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/background"
android:orientation="vertical"
android:paddingTop="@dimen/padding_top"
android:paddingBottom="@dimen/padding_bottom"
android:paddingLeft="@dimen/padding_left"
android:paddingRight="@dimen/padding_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/image"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<View
android:layout_height="@dimen/space_between_image_and_text"
android:layout_width="1dp" />
<TextView
android:text="@string/title_2"
android:textStyle="bold"
android:textColor="@color/text_color_title"
android:singleLine="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="@string/details_2"
android:textColor="@color/text_color_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>