基本上,我正在创建一个android
窗口小部件,其中视图从左到右滚动,具体取决于用户滑动的方向。
以下是我的mail.xml
。有人可以建议我如何制作水平卷轴吗?当我更改此布局时,它会显示:Problem loading widget
。请建议我一个解决方案。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:background="@drawable/background"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/widget1label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/widget1txt"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
答案 0 :(得分:0)
我认为HorizontalScrollView
正是您所寻找的。只需包裹您想要滚动的元素即可。
答案 1 :(得分:0)
<?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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/heading_title"
/>
<ScrollView
android:id="@+id/layout"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:scrollbars="horizontal|vertical"
android:layout_width="fill_parent"
android:layout_marginTop="5dip"
android:scrollbarStyle="outsideInset"
android:fillViewport="true">
<HorizontalScrollView
android:id="@+id/horizontalView"
android:layout_height="fill_parent"
android:scrollbars="horizontal|vertical"
android:layout_width="wrap_content"
android:layout_marginTop="5dip">
............Place all your layouts, views, such as linear layouts, table layouts, etc, that are needed for your app. Note that the TextView for heading/title (see above) will be outside the scrollview, so it will always stay visible at the top. Remove this if not needed, or add there more views as needed .............
</HorizontalScrollView>
</ScrollView>
答案 2 :(得分:0)
所以答案是:如果你熟悉Layouts,创建App Widget布局很简单。但是,您必须意识到App Widget布局基于RemoteViews,它不支持所有类型的布局或视图小部件。
RemoteViews对象(以及App Widget)可以支持以下布局类:
FrameLayout
LinearLayout
RelativeLayout
GridLayout
以下小部件类:
AnalogClock
Button
Chronometer
ImageButton
ImageView
ProgressBar
TextView
ViewFlipper
ListView
GridView
StackView
AdapterViewFlipper