我想用隐藏标题栏滚动整个屏幕,并且我已经在setContentView之前以编程方式请求了全屏...但此请求阻止了scrollview滚动...
下面我提供了样式XML和活动代码,其中我请求fullScreen和fragment.XML我面临滚动问题
style.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="drawerArrowStyle">@style/MyDrawerArrowToggle</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="actionBarStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/black</item>
</style>
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen">
<item name="android:windowFullscreen">true</item>
</style>
<!-- Actionbar Theme -->
<style name="ActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/colorPrimary</item>
</style>
<style name="MyDrawerArrowToggle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="color">@color/white</item>
</style>
<style name="MyDrawerTitle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="color">@color/black</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="EditText.Login" parent="Widget.AppCompat.EditText">
<item name="android:textColor">@android:color/black</item>
<item name="android:textColorHint">@android:color/darker_gray</item>
<item name="colorAccent">@color/colorPrimaryDark</item>
<item name="colorControlNormal">@color/colorPrimary</item>
<item name="colorControlActivated">@color/colorPrimary</item>
</style>
<style name="Widget.MaterialProgressBar.ProgressBar" parent="android:Widget.ProgressBar">
<item name="android:indeterminateDrawable">@null</item>
<item name="android:minWidth">48dp</item>
<item name="android:maxWidth">48dp</item>
<item name="android:minHeight">48dp</item>
<item name="android:maxHeight">48dp</item>
</style>
<color name="black">#000000</color>
<color name="white">#FFFFFF</color>
java代码
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
changeFragment(new WelcomeFragment(), "");
}
public void changeFragment(final Fragment fragment, final String fragmenttag) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction().addToBackStack(null);
fragmentTransaction.replace(R.id.frame, fragment, fragmenttag);
fragmentTransaction.commit();
fragmentTransaction.addToBackStack(null);
}
}, 0);
}
片段xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_30dp"
android:layout_marginRight="@dimen/margin_30dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/tv_notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:padding="@dimen/margin_5dp"
android:text="------------------" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/margin_5dp"
android:text="Notification"
android:textColor="@color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/margin_5dp"
android:text="-----------------" />
</LinearLayout>
<TextView
android:id="@+id/tv_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="@dimen/margin_5dp"
android:text="You Got No Notification"
android:visibility="gone" />
<TextView
android:id="@+id/tv_error1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="----------------------------------------------------------"
android:visibility="gone" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="250dp">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" />
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
<LinearLayout
android:id="@+id/linear_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_20dp"
android:orientation="vertical"
android:visibility="visible">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="@dimen/margin_10dp"
android:text="Number to Navigate to"
android:textColor="@color/black"
android:textSize="@dimen/margin_18sp" />
<EditText
android:id="@+id/et_phone"
android:layout_width="match_parent"
android:layout_height="@dimen/margin_40dp"
android:layout_marginTop="@dimen/margin_5dp"
android:background="@drawable/ic_launcher_background"
android:gravity="center"
android:hint="Enter Number"
android:inputType="number"
android:textSize="@dimen/margin_18sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="@dimen/margin_10dp"
android:text="OR"
android:textColor="@color/black"
android:textSize="@dimen/margin_18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/et_contact"
android:layout_width="match_parent"
android:layout_height="@dimen/margin_40dp"
android:layout_marginTop="@dimen/margin_5dp"
android:background="@drawable/ic_launcher_background"
android:gravity="center"
android:hint="Choose From Contact"
android:inputType="phone"
android:textSize="@dimen/margin_18sp" />
<android.support.v7.widget.AppCompatButton
android:id="@+id/btn_access"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="@dimen/margin_20dp"
android:layout_marginTop="@dimen/margin_20dp"
android:background="@drawable/ic_launcher_background"
android:gravity="center"
android:text="@string/request_access"
android:textColor="@color/colorPrimary" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
答案 0 :(得分:3)
将其添加到ScrollView:
android:fillViewport="true"
您可以将此属性添加到您的活动中:
<activity
android:windowSoftInputMode="stateVisible|adjustResize"
....
/>