我正在尝试为应用程序创建一个小部件,以下是我正在使用的布局.我试图将滚动视图添加到小部件的后半部分.我无法做到这一点,当我删除标签时,小部件正在显示,但是当使用标签时,android无法加载小部件.我这两天都在摸不着头脑.我不明白我做错了什么?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/background_light"
>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/background_dark"
android:id="@+id/widgetHeader"
>
<Button
android:background="@drawable/icon_quickword"
android:id="@+id/widgetBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5sp"
/>
<TextView android:text="@string/widget_title1"
android:id="@+id/widget_title1"
android:textSize="18sp"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="@android:color/white"
android:layout_toRightOf="@id/widgetBtn"
android:layout_marginLeft="2sp"
/>
<TextView android:text="@string/widget_title2"
android:id="@+id/widget_title2"
android:textSize="15sp"
android:textStyle="italic"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="@android:color/white"
android:layout_toRightOf="@id/widgetBtn"
android:layout_below="@id/widget_title1"
android:layout_marginLeft="3sp"
/>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="@+id/widgetContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@android:color/white"
>
<TextView android:text="@string/widget_content_info1"
android:id="@+id/widget_content_info1"
android:textStyle="bold"
android:textSize="16sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="@android:color/black" />
<TextView android:text="@string/widget_content_info2"
android:id="@+id/widget_content_info2"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" …Run Code Online (Sandbox Code Playgroud) 我有一个列表视图。我需要为每个列表项提供一个自定义视图,因此我创建了一个自定义 ListAdapter,它提供了视图和布局,如下所示。但是如何使用 RemoteViews 将这个 listAdapter 设置为小部件中的 ListView ?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/background_light"
android:layout_margin="1sp"
android:padding="10sp"
>
<TextView
android:id="@+id/widgetInfo1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/listItemDummy"
android:textColor="@android:color/black"
/>
<TextView
android:id="@+id/widgetInfo2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/listItemDummy"
android:textColor="@android:color/black"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我正在使用android 2.1开发一个应用程序.为它创建一个小部件,我创建了一个具有文本视图布局,大字体的简单小部件.我想添加可滚动视图,因此如果文本没有框,用户可以滚动.但每当我添加标签.小工具不起作用,任何解决方案?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/background_light"
android:layout_margin="5sp"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="slkjflasjdlkfjaslkjflksjf saldjfslkjdflksf lskjdflkasjdlkfjsa lkfklsa dfsakldjfksajdfkljasdklfjlaksdfkla sdlf askj fljsalfk aslkjfklsdjf lksadkfjsadkljf lksadjkf sadlkjfksa jfkljs dklfj skldjf klsadjkflsa dklfj sadkl fklsadj fklasdj kfjsa dklfjsadkljfklasdjklfsjadfjklsadj;as;fdjaljfd;klajd;klfaklsdjfkas fljldfjasdfjiojsdkljfiowejfisdklfkldjf k kljsedjr ilejicjdisfkeriejfcsdijioerfid cvisdjis kl jiowejfliwejlwjfkjdlkfjsjr i sijflessdf;lejfdejcjwejfij nlkefi ewijtioejifeiofrjiowejflie vilejeijioejfeojvolijsljfoisdjie ff iejieifiejfswjiflisijiejeifjeilfjelis fs ijfis efjsijfilesjflsjlfe sif j"
android:textSize="15sp"
/>
</ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)