用于setVisibility
在背景中隐藏具有自己样式的布局。像这样:
public static void changeWidgetState(RemoteViews remoteView, int state){
switch (state){
case 0:{
remoteView.setViewVisibility(R.id.widgetLayout1, View.VISIBLE);
remoteView.setViewVisibility(R.id.widgetLayout2, View.GONE);
} break;
case 1:{
remoteView.setViewVisibility(R.id.widgetLayout1, View.GONE);
remoteView.setViewVisibility(R.id.widgetLayout2, View.VISIBLE);
} break;
...
default:
}
}
xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widgetLayout0"
android:layout_width="150dip"
android:layout_height="wrap_content"
>
<!--Normal Theme Black Text -->
<RelativeLayout
android:id="@+id/widgetLayout1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
style="@style/WidgetBackgroundNormal"
/>
<!--Yellow Theme Black Text -->
<RelativeLayout
android:id="@+id/widgetLayout2"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
style="@style/WidgetBackgroundYellow"
/>
...
<LinearLayout
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:paddingTop="7dip"
>
<TextView
android:id="@+id/widget_server_name"
style="@style/Text.DefinitionWhite"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dip"
/>
....
</LinearLayout>
</RelativeLayout>