Android 小部件Listview应该与我的普通Listview相同
如何使我的listvew和小部件listview看起来相同?我的意思是,它看起来应该是一样的,因为它在XML中具有相同的布局样式,但编辑文本除外,因为编辑文本在小部件中是不允许的。我在我的android清单上的每个活动上都添加了@android:style/Theme.Light,但这个小部件仍然是半透明的 请点击链接查看照片 这是普通listvew的布局Android 小部件Listview应该与我的普通Listview相同,android,listview,android-widget,android-theme,Android,Listview,Android Widget,Android Theme,如何使我的listvew和小部件listview看起来相同?我的意思是,它看起来应该是一样的,因为它在XML中具有相同的布局样式,但编辑文本除外,因为编辑文本在小部件中是不允许的。我在我的android清单上的每个活动上都添加了@android:style/Theme.Light,但这个小部件仍然是半透明的 请点击链接查看照片 这是普通listvew的布局 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/a
<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>
安卓清单
<?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>
`
你说的“看起来一样”是什么意思"? 因为基于你给的图像,它们实际上在我看来是一样的,取而代之的是小部件有一个透明的背景,当然还有一个空白,因为它不会占据整个屏幕空间。这就是你想要消除的差异吗?是的,我不明白为什么它是透明的。顺便说一句,每款手机的外观都不一样。我不希望它是透明的。您是否尝试在ListView或LinearLayout中添加背景色?不,我没有。我所做的是将其放置在android清单上的活动android:theme=“@style/theme.Base.Light”中。我尝试将android:background=“#ffffffff”添加到列表视图中,但看起来不一样。也许我在清单上放置主题的位置有问题?我将在此处发布。