我试图像这样以编程方式填充线性布局
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT
);
params.setMargins(dpToPx(6), 0, 0, 0);
kac.setLayoutParams(params);
LinearLay.addView(kac);
Run Code Online (Sandbox Code Playgroud)
我希望在我的xml中添加(在每个TextView(如kac)之后)像我这样的水平线
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#B3B3B3"
android:padding="10dp"
/>
Run Code Online (Sandbox Code Playgroud) 我试图在 android 应用程序 WIDGET xml 中的所有 TextViews 下方添加一条水平线,但我有一个问题,由于某种原因,这不起作用。
编辑:这是我在应用程序中使用的小部件的完整 xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/liner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical" >
<TextView
android:id="@+id/da"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/sv"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#B3B2B0"
android:padding="10dp" />
<TextView
android:id="@+id/ti"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)