【发布时间】:2017-02-02 19:01:38
【问题描述】:
我的片段 (FrameLayout) (w: match_parent, h: fill_parent) 有两个包含布局:
-
ScrollView(w:match_parent,h:fill_parent) -
LinearLayout(w:match_parent,h:wrap_content)
我不明白,为什么 LinearLayout 只是覆盖了 ScrollView。我想让ScrollView 停在LinearLayout 的拐角处
<FrameLayout 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"
tools:context="com.my.stackoverflow.example.problemFragment">
<!-- This is my Scrollview with an dynamic nums of TxtViews (Added by onViewCreated in my Fragment) -->
<ScrollView
android:id="@+id/ScrollViewId"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top">
<LinearLayout
android:id="@+id/MessagesId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
<!-- Following a LinearLayout wich containing an EditBox and a Button)
Take a look at the bg color, maybe helpful for you?-->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@color/colorWhite"
android:layout_gravity="bottom"
android:gravity="bottom">
<EditText
android:id="@+id/MessageEditText"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="Enter Message"
android:inputType="textAutoComplete"
android:textSize="20sp"
android:background="@color/colorWhite"
android:layout_marginLeft="5dp"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:paddingLeft="12dp"
android:layout_weight="1"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="10dp"
android:foregroundGravity="center"
android:background="@drawable/circle"/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="5dp"
android:tint="@color/colorWhite"
android:background="@drawable/ic_send_black_24dp"/>
</RelativeLayout>
</LinearLayout>
我的解决方案:
我已将 android:layout_marginBottom="50dp" 添加到我的 ScrollView 并将我的 LinearLayout 高度从 wrap_content 设置为 android:layout_height="50dp"
我认为这不是一个干净的解决方案,但它对我有用。
【问题讨论】:
-
Altought 这可能无法解决您的问题:fill_parent 已被弃用。请改用 match_parent。另外:发布您的活动 xml 文件,以便我们为您提供帮助
-
我已经更新了我的问题
标签: android android-layout scrollview android-linearlayout