我正在尝试创建一个应用程序,它只是一个包含文本、按钮等的简单列表......
但该列表太大,不适合移动屏幕。所以我尝试制作一个ScrollView,但它不起作用。
编辑:滚动在手机上不起作用。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.blabla.tddddd.MainActivity" >
<ScrollView
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/feedback_send"
android:fillViewport="true" >
<RelativeLayout
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Aksjasjjs"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textStyle="bold|italic" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="KSADKDSK"
android:id="@+id/textView2"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="29dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="salSKXAska"
android:id="@+id/textView3"
android:layout_below="@+id/textView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="29dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="SKakas"
android:id="@+id/textView4"
android:layout_marginTop="66dp"
android:layout_below="@+id/textView3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="sassa"
android:id="@+id/textView5"
android:layout_marginTop="87dp"
android:layout_below="@+id/textView4"
android:layout_alignParentLeft="true" …Run Code Online (Sandbox Code Playgroud) android scrollview android-linearlayout android-relativelayout
我正在尝试创建一个看起来像这样的简单UI
我是android的新手,并且一直在尝试不同类型的布局(线性/相对),我相信Linear可能是这里的方式(我希望在某个阶段使ListViews的数量动态,但现在2很好) .
我应该使用线性布局或相对布局,还是两者的某种组合来实现此目的.
这是我拥有的XML,即使它的重力设置为正确,我似乎无法使按钮正确对齐.我愿意接受有关如何解决此问题的任何建议,或者是否有更好的方法
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9"
android:orientation="horizontal" >
<ListView
android:id="@+id/lv1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
/>
<ListView
android:id="@+id/lv2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="New Button"
android:id="@+id/button"
android:gravity="right" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
编辑:这是UI目前的样子
xml user-interface android android-linearlayout android-relativelayout
我有太多的相对布局,我想转换它看起来像卡.如何我可以使drawable看起来像卡.我想使它像行一样的矩形形状.
我是Android开发的新手.
我正在使用以下RelativeLayout.
我希望我的txtView1高于lstAnswers,但layout_below不起作用,并且视图被覆盖.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:background="#ffbad6e6"
tools:context="com.example.user.myApp.QuestionDetails">
<TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtView1"
android:textColor="#ff0d5e52"/>
<ListView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/lstAnswers"
android:layout_centerHorizontal="false"
android:paddingTop="50dp"
android:layout_alignParentTop="true"
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
android:layout_below="@id/txtView1"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我也尝试使用@ + id设置layout_below,如下所示:
android:layout_below="@+id/txtView1"
Run Code Online (Sandbox Code Playgroud)
但这没有给我什么.
任何人都可以解释我如何在lstAnswers上面设置txtView1?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.testing.testinglibraryapps.Main2Activity">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
如何将Android屏幕分为两部分.即一个相对布局应位于屏幕的3/4部分,其他布局应为1/4
我应该在这里设置什么属性来实现我想要的布局