如何让listvew和widget listview看起来一样?我的意思是它应该看起来一样,因为除了编辑文本之外,它在XML中具有相同的布局样式,因为在窗口小部件中不允许编辑文本。我在我的Android清单上的每个活动上添加了@android:style / Theme.Light,但是小部件仍然是半透明的。
请点击链接查看照片。
这是普通listvew的布局。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:minWidth="250dp"
android:minHeight="250dp"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/imageView"
android:src="@drawable/find_icon"
android:maxHeight="5dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/search"
android:inputType="text"
android:ems="10"
android:focusableInTouchMode="true"
>
<!--android:focusable="true"-->
<!-- <requestFocus />-->
</EditText>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Donate to Charities"
android:id="@+id/donate_Button"
/>
</LinearLayout>
这是小部件列表视图的xml。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/imageView"
android:src="@drawable/find_icon"
android:maxHeight="5dp" />
<TextView
android:id="@+id/textDummy"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
style="@android:style/Widget.EditText"
android:clickable="true"
>
</TextView>
<!--<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Click to search."
android:id="@+id/Search Button"
android:layout_weight="1"
/>
-->
<requestFocus />
</LinearLayout>
<ListView
android:id="@+id/listViewWidget"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Donate to Charities"
android:id="@+id/donate_Button"
/>
</LinearLayout>
Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ddd.listapp.app"
android:versionCode="3"
android:versionName=".103"
>
<application
android:allowBackup="true"
android:debuggable="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light"
>
<!-- android:theme="@style/Theme.D1NoTitleDim"-->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".DonateBillingActivity"
android:label="@string/title_activity_donate_billing"
android:theme="@android:style/Theme.Light"
>
</activity>
<activity
android:name=".CallApplicationActivityfromWidget"
android:theme="@android:style/Theme.Light"
>
</activity>
<!-- <activity android:name=".SearchListWidgetConfigureActivity" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>-->
<receiver android:name=".SearchListWidget"
android:theme="@android:style/Theme.Light"
>
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/search_list_widget_info" />
</receiver>
<activity
android:name=".SearchFieldActivityforWidget"
android:label="@string/title_activity_search_field_activityfor_widget"
android:theme="@android:style/Theme.Light"
>
<!--android:theme="@style/Theme.D1NoTitleDim"-->
</activity>
<service
android:name=".WidgetService"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BIND_REMOTEVIEWS"
>
</service>
</application>
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<compatible-screens>
<!-- no small size screens -->
<!-- all normal size screens -->
<screen
android:screenDensity="ldpi"
android:screenSize="normal" />
<screen
android:screenDensity="mdpi"
android:screenSize="normal" />
<screen
android:screenDensity="hdpi"
android:screenSize="normal" />
<screen
android:screenDensity="xhdpi"
android:screenSize="normal" />
<!-- all large size screens -->
<screen
android:screenDensity="ldpi"
android:screenSize="large" />
<screen
android:screenDensity="mdpi"
android:screenSize="large" />
<screen
android:screenDensity="hdpi"
android:screenSize="large" />
<screen
android:screenDensity="xhdpi"
android:screenSize="large" />
<!-- all xlarge size screens -->
<screen
android:screenDensity="ldpi"
android:screenSize="xlarge" />
<screen
android:screenDensity="mdpi"
android:screenSize="xlarge" />
<screen
android:screenDensity="hdpi"
android:screenSize="xlarge" />
<screen
android:screenDensity="xhdpi"
android:screenSize="xlarge" />
<!-- Special case for Nexus 7 -->
<screen
android:screenDensity="213"
android:screenSize="large" />
<screen
android:screenDensity="480"
android:screenSize="normal" />
<screen
android:screenDensity="480"
android:screenSize="large" />
<screen
android:screenDensity="480"
android:screenSize="xlarge" />
`
</compatible-screens>
<uses-permission android:name="com.android.vending.BILLING" />
</manifest>