[英]Linear layout within relativelayout not perfect the fullscreen fit
Linerlayout will be not fit in full screen white background color displaying .. Any ideas on making both sides Fit in fullscreen? Linerlayout将不适合全屏白色背景颜色显示..关于使两面都适合全屏的任何想法?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"\>
<Button
android:id="@+id/bClose"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_margin="0dp"
android:background="@drawable/round_button_background"
android:gravity="center_vertical|center_horizontal"
android:onClick="cancelActivity"
android:text="@string/x_close"
android:textColor="#FFF"
android:textSize="15sp"
android:textStyle="bold"
android:layout_alignParentTop="true"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:fillViewport="true"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/preview_frag"
android:focusable="true">
<requestFocus />
</LinearLayout>
</RelativeLayout>
Can you try it using webview? 您可以使用webview尝试吗? adjust webview by implementing padding and margin in it.... use -(negative) values
通过在其中实现填充和边距来调整Web视图。...使用-(负)值
This works totally fine. 这完全正常。 Try using match_parent instead of fill_parent.
尝试使用match_parent而不是fill_parent。 Check if the image has white space.
检查图像是否有空白。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/bClose"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_margin="0dp"
android:background="@drawable/ic_event_white_24dp"
android:gravity="center_vertical|center_horizontal"
android:text="close"
android:textColor="#FFF"
android:textSize="15sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/preview_frag"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:focusable="true"
android:background="@color/theme_primary"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal">
<requestFocus />
</LinearLayout>
</RelativeLayout
The layout is correct, probably the issue is in the fragment layout since your LinearLayout
seems to be a fragment container. 布局正确,可能是片段布局中的问题,因为您的
LinearLayout
似乎是片段容器。 Check if your fragment_layout has some margin or padding. 检查您的fragment_layout是否有空白或填充。 Also as a suggest you should change from
fill_parent
to match_parent
另外建议您将
fill_parent
更改为match_parent
Try this 尝试这个
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/bClose"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_margin="0dp"
android:background="@drawable/round_button_background"
android:gravity="center_vertical|center_horizontal"
android:onClick="cancelActivity"
android:text="@string/x_close"
android:textColor="#FFF"
android:textSize="15sp"
android:textStyle="bold"
android:layout_alignParentTop="true"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:fillViewport="true"
android:gravity="center_vertical|center_horizontal"
android:id="@+id/preview_frag"
android:focusable="true">
<requestFocus />
</LinearLayout>
</RelativeLayout>
If you are looking to have the close button on top of the LinearLayout
, you can try using the parent view as FrameLayout
, something like so :- 如果您希望在
LinearLayout
顶部具有关闭按钮,则可以尝试将父视图用作FrameLayout
,如下所示:-
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/frameLayout1">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linearLayout1"
android:background="@android:color/holo_blue_bright" />
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button1"
android:layout_gravity="right" />
</FrameLayout>
replace height and width property fill_parent to match_parent remove gravity from LinearLayout try above code 将height和width属性fill_parent替换为match_parent,从LinearLayout中删除重力,尝试上面的代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/bClose"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_margin="0dp"
android:background="@drawable/round_button_background"
android:gravity="center_vertical|center_horizontal"
android:onClick="cancelActivity"
android:text="@string/x_close"
android:textColor="#FFF"
android:textSize="15sp"
android:textStyle="bold"
android:layout_alignParentTop="true"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/preview_frag">
</LinearLayout>
</RelativeLayout>
Try this 尝试这个
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/bClose"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_margin="0dp"
android:background="@drawable/blockclose"
android:gravity="center_vertical|center_horizontal"
android:onClick="cancelActivity"
android:text="x_close"
android:textColor="#FFF"
android:textSize="15sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/preview_frag"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="@drawable/bg"
android:focusable="true"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal">
<requestFocus />
</LinearLayout>
</RelativeLayout>
if you are using imageview try using 如果您正在使用imageview尝试使用
android:scaleType="fitXY"
i also face the same problem, by giving negative margin values its works fine for me example code 我也面临同样的问题,通过给定负的边距值,对我来说效果很好
<body style='margin:-0.5px;'>
i hope above code will works for you 我希望以上代码对您有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.