Android-Border围绕ListFragment?
我有一个活动,该活动的xml文件中包含一个ListFragmentAndroid-Border围绕ListFragment?,android,xml,android-fragments,border,Android,Xml,Android Fragments,Border,我有一个活动,该活动的xml文件中包含一个ListFragment <fragment android:id="@+id/shoppingListNamesFragment" android:name="com.example.ShoppingListNamesFragment" android:layout_below="@id/shoppingListsTitle" android:layout_width="match_parent" andr
<fragment
android:id="@+id/shoppingListNamesFragment"
android:name="com.example.ShoppingListNamesFragment"
android:layout_below="@id/shoppingListsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
…但它不会创建边框,而如果我将这3行添加到xml,例如,添加到LinearLayout,它会创建边框
理想情况下,如何使用xml向ListFragment添加边框
PS-有一个类似的问题建议添加父布局,但我希望尽可能避免这种情况。将边框添加到ListFragment布局xml的根元素:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/white_dashed_border"
android:padding="14dp"
android:layout_margin="14dp">
可能会非常容易地帮助您,对于这个特定的案例片段和任何小部件都是如此。
它使您能够将任何想要的小部件包装在预先制作的、可配置的带边框的框架布局中。您需要将边框放在fragments布局的根元素上,您是否有权更改ShoppingListNamesFragment片段的代码,或者它位于您无法控制的库中?如果您可以更改代码,您可以有一个自定义主题,您可以将其应用于添加可绘制为背景的边框形状的片段。看看这个:干杯,但是线性布局中还有其他元素,我不希望边界出现。如果没有包含所述片段子元素的边界,您打算如何在整个片段周围添加边界。。?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/white_dashed_border"
android:padding="14dp"
android:layout_margin="14dp">