[英]How to add both horizontal and vertical view in a single activity.
I want to add horizontal and vertical scroll in one activity. 我想在一个活动中添加水平和垂直滚动。 But i can not add both. 但是我不能同时添加两者。 I have follow some examples. 我有一些例子。 But my application crashes and force close. 但是我的应用程序崩溃并强制关闭。
I have follow this links. 我点击了此链接。
My requirement is:- 我的要求是:-
Top is horizontal scroll, Bottom is vertical scroll. 顶部是水平滚动,底部是垂直滚动。
I have try like this:- 我有这样的尝试:
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@android:drawable/btn_star" />
</LinearLayout>
</HorizontalScrollView>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView android:id ="@+id/labelA"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Name:"
android:layout_x="0px"
android:layout_y="5px"
/>
<EditText android:id="@+id/edtInput"
android:layout_x="0px"
android:layout_y="40px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
/>
<TextView android:id ="@+id/labelB"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Email:"
android:layout_x="0px"
android:layout_y="110px"
/>
<EditText android:id="@+id/edtInputA"
android:layout_x="0px"
android:layout_y="150px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
/>
<Button android:id ="@+id/btnClick"
android:layout_width="180px"
android:layout_height="70px"
android:text="Open New Screen"
android:textSize="14px"
android:layout_x="0px"
android:layout_y="235px"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
Please let me know any idea to achieve this. 请让我知道实现此目标的任何想法。 Thanks in advance. 提前致谢。
I don't understand the problem. 我不明白这个问题。 Maybe this might help to achieve it, you should put all in RelativeLayout
and add its attributes as follows: 也许这可能有助于实现它,您应该将其全部放入RelativeLayout
并添加其属性,如下所示:
<RelativeLayout
... >
<HorizontalScrollView
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<!-- other views -->
</LinearLayout>
</HorizontalScrollView>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/header" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<!-- other views -->
</LinearLayout>
</ScrollView>
</RelativeLayout>
Let me know if this helps. 让我知道是否有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.