在android小部件中添加水平线
我试图在android应用程序小部件xml中添加一条横线来显示我所有的文本视图,但我遇到了一个问题,出于某种原因,这不起作用 编辑:这是我在应用程序中使用的小部件的完整xml在android小部件中添加水平线,android,android-widget,Android,Android Widget,我试图在android应用程序小部件xml中添加一条横线来显示我所有的文本视图,但我遇到了一个问题,出于某种原因,这不起作用 编辑:这是我在应用程序中使用的小部件的完整xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" and
<?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>
您的问题是小部件不支持您所看到的视图。在您的情况下,可以将该视图替换为如下所示的线性布局:
<LinearLayout
android:id="@+id/widget_horizontal_white_bar"
android:layout_width="fill_parent"
android:layout_height="3dip"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="6dp"
android:background="#FFFFFF"
android:orientation="horizontal" >
</LinearLayout>
因为它是一个小部件中的远程视图,我想这是个问题,在正常的MainActivity.class中,我可以使用它,但在AppWidget.class中,当我的小部件出现问题时,它会说显示小部件有问题……你能粘贴封装的XML吗?可能是视图在继承人结构中的位置有问题。您知道如何通过编程方式删除层updateViews.remove…类似于..?这应该可以工作:view widget\u horizontal\u white\u bar=view.findViewById(R.id.widget\u horizontal\u white\u bar);((LinearLayout)小部件水平白条.getParent()).removeView(小部件水平白条)如果您不想将视图从视图的三个视图中删除,请使用code>或将视图设置为不可见的或消失的((LinearLayout)findViewById(R.id.widget\u horizontal\u white\u bar))。设置可见性(view.GONE)代码>