【问题标题】:SwipeRefreshLayout with CardView issueSwipeRefreshLayout 与 CardView 问题
【发布时间】:2017-08-16 13:11:24
【问题描述】:

我创建了具有 SwipeRefresh 的视图。我在底部还有两个按钮,因此当点击edittext时它们可以通过软键盘向上移动。问题是当文本框被点击时,按钮在顶部,但我认为 cardview 具有更高的 z-index 并且它们不完全可见

有一个结构:

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/refresher"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:fillViewport="true">
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginTop="15px">
       
            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/card_margin">
                 <!-- textboxes and others  components here -->
            </android.support.v7.widget.CardView>
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_below="@+id/spinner"
                android:layout_marginTop="5px"
                android:gravity="center_horizontal|bottom"
                android:paddingTop="2px">
                <Button
                    android:theme="@style/AppTheme.ButtonAccent"
                    android:layout_width="0dip"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:id="@+id/startBtn"
                    android:text="START" />
                <Button
                    android:theme="@style/AppTheme.ButtonPrimaryLight"
                    android:layout_width="0dip"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                     android:id="@+id/continueBtn"
                    android:text="CONTINUE WORK" />
            </LinearLayout>
        </RelativeLayout>
    </ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>

我应该手动将按钮的 z 索引设置为更高,还是有更好的选择让它工作?

【问题讨论】:

  • 为什么要去掉这个问题?
  • 设置卡片视图下方的按钮
  • 下面有
  • 你在Activity标签的manifest中添加了这个android:windowSoftInputMode="adjustResize"

标签: android xml android-layout android-cardview swiperefreshlayout


【解决方案1】:

如果它高于版本 21,则为您的线性布局包含按钮与卡片视图相同的高度。 因为卡片视图有z轴,它需要高度,而线性布局没有高度。 但是,如果您使用的是低于 21 的版本,那么您可以将 线性布局保留在卡片视图中,并为其设置与上方相同的高度。


我希望它对你有用............


【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多