【发布时间】:2014-11-26 11:44:27
【问题描述】:
我的项目是创建 email 字段 dynamic ,从某种意义上说,我可以有一个、两个和其他。所以我想把整个右侧的细节放在 ScrollView 中。问题是 scoolview 永远不会出现,不可滚动并且无法找出问题所在,我不希望它适合屏幕,但您可以滚动。有人能帮我吗 ?非常感谢
main.xml
<?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"
android:weightSum="10" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:orientation="horizontal"
android:weightSum="10" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:orientation="vertical"
android:weightSum="10" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:scaleType="fitStart"
android:src="@drawable/user" />
</LinearLayout>
<ScrollView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="7"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="21" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:orientation="horizontal"
android:weightSum="10" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="5"
android:orientation="vertical"
android:weightSum="10" >
<TextView
android:id="@+id/labelname"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@color/gray"
android:drawableLeft="@drawable/ic_action_person"
android:gravity="left|center_vertical"
android:text=" Name"
android:textSize="@dimen/campaign_textfontsize_label" />
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="7"
android:background="@drawable/edit_text"
android:gravity="center_vertical"
android:hint="Nome"
android:imeOptions="actionDone"
android:inputType="textCapSentences|textAutoCorrect"
android:singleLine="true"
android:textSize="@dimen/campaign_textfontsize" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="5"
android:orientation="vertical"
android:weightSum="10" >
<TextView
android:id="@+id/labelsurname"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@color/gray"
android:drawableLeft="@drawable/ic_action_person"
android:gravity="left|center_vertical"
android:text=" Surname"
android:textSize="@dimen/campaign_textfontsize_label" />
<EditText
android:id="@+id/surname"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="7"
android:background="@drawable/edit_text"
android:gravity="center_vertical"
android:hint="Surname"
android:imeOptions="actionDone"
android:inputType="textCapSentences|textAutoCorrect"
android:singleLine="true"
android:textSize="@dimen/campaign_textfontsize" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/labelemail"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/gray"
android:drawableLeft="@drawable/ic_action_email"
android:gravity="left|center_vertical"
android:text=" E-Mail"
android:textSize="@dimen/campaign_textfontsize_label" />
<EditText
android:id="@+id/emailHome"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@drawable/edit_text"
android:gravity="center_vertical"
android:hint="E-Mail"
android:imeOptions="actionDone"
android:inputType="textCapSentences|textAutoCorrect"
android:singleLine="true"
android:textSize="@dimen/campaign_textfontsize" />
<EditText
android:id="@+id/emailWork"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@drawable/edit_text"
android:gravity="center_vertical"
android:hint="E-Mail"
android:imeOptions="actionDone"
android:inputType="textCapSentences|textAutoCorrect"
android:singleLine="true"
android:textSize="@dimen/campaign_textfontsize" />
<EditText
android:id="@+id/emailOther"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@drawable/edit_text"
android:gravity="center_vertical"
android:hint="E-Mail"
android:imeOptions="actionDone"
android:inputType="textCapSentences|textAutoCorrect"
android:singleLine="true"
android:textSize="@dimen/campaign_textfontsize" />
<EditText
android:id="@+id/emailMobile"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@drawable/edit_text"
android:gravity="center_vertical"
android:hint="E-Mail"
android:imeOptions="actionDone"
android:inputType="textCapSentences|textAutoCorrect"
android:singleLine="true"
android:textSize="@dimen/campaign_textfontsize" />
<TextView
android:id="@+id/labelnumber"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/gray"
android:drawableLeft="@drawable/ic_action_dial_pad"
android:gravity="left|center_vertical"
android:text=" Telefono"
android:textSize="@dimen/campaign_textfontsize_label" />
<EditText
android:id="@+id/number"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@drawable/edit_text"
android:focusableInTouchMode="true"
android:gravity="center_vertical"
android:hint="Number"
android:imeOptions="actionDone"
android:inputType="phone"
android:singleLine="true"
android:textSize="@dimen/campaign_textfontsize" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="10" >
<Button
android:id="@+id/save"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="@drawable/color_button"
android:clickable="true"
android:drawableStart="@drawable/ic_action_save"
android:focusable="true"
android:text="Save"
android:textColor="#78858B"
android:textStyle="bold" />
<Button
android:id="@+id/delete"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="@drawable/color_button"
android:clickable="true"
android:drawableStart="@drawable/ic_action_discard"
android:focusable="true"
android:text="Delete"
android:textColor="#78858B"
android:textStyle="bold" />
<Button
android:id="@+id/cancel"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="@drawable/color_button"
android:clickable="true"
android:drawableStart="@drawable/ic_action_cancel"
android:focusable="true"
android:text="Cancel"
android:textColor="#78858B"
android:textStyle="bold" />
<Button
android:id="@+id/add"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/color_button"
android:clickable="true"
android:drawableStart="@drawable/ic_action_add_person"
android:focusable="true"
android:textColor="#78858B"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
【问题讨论】:
-
嘿,将你的滚动视图高度设置为某个静态值,这样它就会准确地显示你的高度,而且它也是可滚动的。
-
我尝试以 700dp 为例,正常但不滚动,保持固定
-
意味着700dp是你所有的内容都可以看到吗?将您的高度设置为 100 dp,然后检查它。
-
不起作用,我认为放置固定大小对我没有用,因为 ScrollView 有重量,然后您必须适应我使用的任何设备上的页面
标签: android xml scrollview android-linearlayout android-layout-weight