Android安装程序滚动视图和相对布局
我有下一个代码:Android安装程序滚动视图和相对布局,android,android-layout,android-scrollview,Android,Android Layout,Android Scrollview,我有下一个代码: <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView2" android:layout_below="@+id/editText1"
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_below="@+id/editText1"
android:layout_marginTop="30dp"
android:text="@string/cm_diameter"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_below="@+id/textView3"
android:layout_marginTop="28dp"
android:text="@string/from"
android:textAppearance="?android:attr/textAppearanceSmall" />
我使用的参数连接到相对布局
我想使用滚动视图包装此文本视图(我还有其他视图) 我的图像显示滚动视图(绿色视图),滚动视图下方显示另一个容器(黑色视图)。我怎样才能达到这个结果 我曾尝试在滚动视图中使用线性布局,但结果与我预期的不同
如果我正确理解了您的意思,希望这个例子能帮助您开始学习。(如果没有,我道歉。)
如果我正确理解了您的意思,希望这个例子能帮助您开始学习。(如果没有,我道歉。)
我不知道你到底放了什么安卓:布局。但是,正如你上面的设计,我试图为这个做一个简单的布局,我认为这是可行的
<?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:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#ff00ff00" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calculation" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="30dip"
android:text="Item1"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="30dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
</LinearLayout>
</ScrollView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff000000"
android:padding="20dip" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Add parameter" />
</FrameLayout>
是吗?我不知道你到底放了什么android:layout\u marginTop。但是,正如你上面的设计,我试图为这个做一个简单的布局,我认为这是可行的
<?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:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#ff00ff00" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calculation" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="30dip"
android:text="Item1"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="30dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="60dip"
android:text="Another text view for test"
android:textAppearance="@android:style/TextAppearance.Large" />
</LinearLayout>
</ScrollView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff000000"
android:padding="20dip" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Add parameter" />
</FrameLayout>
是吗?+1000漂亮的背景。所以您希望绿色区域滚动,黑色区域始终位于屏幕底部?@user2145222谢谢。黑色区域不会随滚动一起滚动。黑色区域位于滚动视图下。“我想使用滚动视图包装此文本视图(我还有其他视图)。”您到底想要什么?你能澄清一下吗?@hieuxit我的意思是,我想把几个视图放到滚动视图中,但使用相对布局。在“滚动视图”下,我想有另一个视图。+1000良好的背景。所以您希望绿色区域滚动,黑色区域始终位于屏幕底部?@user2145222谢谢。黑色区域不会随滚动一起滚动。黑色区域位于滚动视图下。“我想使用滚动视图包装此文本视图(我还有其他视图)。”您到底想要什么?你能澄清一下吗?@hieuxit我的意思是,我想把几个视图放到滚动视图中,但使用相对布局。在“滚动视图”下,我希望有另一个视图。感谢您的回答,但由于我认为我的代码中的这些参数将不起作用。我的意思是关于android:layout_marginTop=“30dp”etc@MatrosovAlexander我很困惑,在名为“mainbody”的线性布局中添加行“android:layout_marginTop=“30dp”效果很好。如果您愿意,您也可以将其添加到scrollview本身,因为在我的示例中它位于相对布局内。感谢您的回答,但我认为我的代码中的这些参数将不起作用。我的意思是关于android:layout_marginTop=“30dp”etc@MatrosovAlexander我很困惑,在名为“mainbody”的线性布局中添加行“android:layout_marginTop=“30dp”效果很好。如果您愿意,您也可以将其添加到scrollview本身,因为在我的示例中,它位于相对布局中。如果您希望使用marginTop为第一个视图提供另一个空间,则可以将其添加到scrollview本身。如果希望使用marginTop为第一个视图留出另一个空间,则不应在父线性布局中使用。不应在父线性布局中使用