首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当滚动条集中在editText上时,如何使其上有状态栏的全屏活动不全滚动?

当滚动条集中在editText上时,如何使其上有状态栏的全屏活动不全滚动?
EN

Stack Overflow用户
提问于 2019-09-22 07:12:57
回答 3查看 656关注 0票数 2

问题是,当我在EditText中输入文本时,ScrollView在我的活动中不工作,也不会滚动。

代码语言:javascript
运行
复制
     fun statusBarColor(activity: Activity) {


     val window = activity.window
    // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
    window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
   // clear FLAG_TRANSLUCENT_STATUS flag:
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
 //window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);            
    // finally change the color
    //window.statusBarColor = ContextCompat.getColor(activity, R.color.colorPrimaryDark)
    //window.setStatusBarColor(Color.TRANSPARENT);

}
      //Manifest code on activity.
       android:windowSoftInputMode="adjustResize">
EN

回答 3

Stack Overflow用户

发布于 2019-09-22 07:27:55

您可以使用CoordinatorLayout作为根目录,并在其中使用NestedScrolView

CoordinatorLayout作为根用户响应键盘,并使用NestedScrollView的助手( NestedScrollView包含布局代码)将布局滚动到手机顶部。

将这一问题纳入透视观点

CoordinaterLayout > NestedScrolView > yourLayout

按照下面的代码更改布局XMl

代码语言:javascript
运行
复制
<android.support.design.widget.CoordinatorLayout
    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">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <!-- rest of your layout xml code-->

    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
票数 2
EN

Stack Overflow用户

发布于 2022-04-27 00:55:18

代码语言:javascript
运行
复制
getWindow().setBackgroundDrawableResource(R.drawable.iv_background);

initViews()设置为SignIn活动,并使其透明:

代码语言:javascript
运行
复制
 <item name="colorPrimaryVariant">#00000000</item>
票数 0
EN

Stack Overflow用户

发布于 2022-04-27 06:56:23

您可以通过拥有一个活动和内容布局文件来实现这一点。从您的例子来看,我们可以使用activity_login和content_login。在本例中,我将假设您的活动名为LoginActivity.class,因此请相应更新。

activity_login.xml

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    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"
    android:orientation="vertical"
    tools:context=".LoginActivity">

    <include layout="@layout/content_user_profile" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

content_user_profile

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 
    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"
    android:animateLayoutChanges="true"
    android:background="@color/color_white"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".LoginActivity"
    tools:showIn="@layout/activity_login">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <!--Have all your layout here as scrollviews expect one child. You can replace LinearLayout above with constraintLayout for more flexibility and responsiveness.-->

    </Linearlayout>
</androidx.core.widget.NestedScrollView>

特定活动的清单代码

代码语言:javascript
运行
复制
<activity
    android:name=".LoginActivity"
    android:colorMode="wideColorGamut"
    android:exported="true"
    android:label="@string/title_activity_login"
    android:theme="@style/..."
    android:windowSoftInputMode="adjustPan" />
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58046939

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档