Android布局在布局预览中显示在屏幕上
我正在做一个小项目,突然布局预览开始出现问题。它从屏幕上出来了。布局高度或宽度都不是这样!!你可以通过这些图像得到清晰的图像 这是第二幅图像: 很明显,蓝色的边框从屏幕上出来了 我在SO中发现了这个问题,但它与我的问题无关 这些就是我尝试过的东西 清理并使项目不起作用 重建项目没有成功 无效缓存并重新启动Android Studio也不起作用:/ 这是activity_details.xml的xml代码Android布局在布局预览中显示在屏幕上,android,xml,layout,view,Android,Xml,Layout,View,我正在做一个小项目,突然布局预览开始出现问题。它从屏幕上出来了。布局高度或宽度都不是这样!!你可以通过这些图像得到清晰的图像 这是第二幅图像: 很明显,蓝色的边框从屏幕上出来了 我在SO中发现了这个问题,但它与我的问题无关 这些就是我尝试过的东西 清理并使项目不起作用 重建项目没有成功 无效缓存并重新启动Android Studio也不起作用:/ 这是activity_details.xml的xml代码 <?xml version="1.0" encoding="utf-8"?> &
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="bk.photoorganizer.DetailsActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/photos_rec_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_gravity="bottom|end"/>
</android.support.design.widget.CoordinatorLayout>
这是activity_main.xml的xml代码:
<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="bk.photoorganizer.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="#ffffff"
app:tabIndicatorHeight="2dp"
app:tabSelectedTextColor="#ffffff"
app:tabTextAppearance="@style/tabText"
app:tabTextColor="#63FFFFFF"
/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
提前感谢…您可以使用此解决方案来控制视图外观:
<?xml version="1.0" encoding="utf-8"?>
<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"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/appbar">
<include layout="@layout/list_elec"
/>
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
包含的布局应为框架布局:
发布xml代码,这将是一个好主意。当然,请稍等。@bharath使用RelativeLayout而不是CoordinatorLayout。实际上问题不在于布局。它与协调器布局配合得很好,当我从睡眠中再次打开笔记本电脑时,它的行为不端,请尝试退出android studio并再次打开它。感谢兄弟帮了我的忙!!
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/photos_rec_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_gravity="bottom|end"/>
</FrameLayout>