Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unless I don't fully understand your issues with using <code>android:padding</code> to provide space around your layout, you should be able to use <code>android:layout_margin</code> instead to accomplish the same goal but overcome the problems you mentioned. Adding padding creates space between the border of the View and its content. However, adding margin creates space between the border of the View and its parent, so the content still fills the View itself to the edges. However, you still can't define your view spacing in terms of percentage direct from XML...you would need to define the margin as static or apply the <code>LayoutParams</code> in Java code where you could calculate the required margin based on the current screen size.</p> <p>Another option is to take advantage of the <code>android:layout_weight</code> property inside of a nested <code>LinearLayout</code>. The calculated weight sum could give you the 60% you're looking for directly in XML. Something like this:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:weightSum="1.0" &gt; &lt;LinearLayout android:orientation="vertical" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="0.6" android:gravity="center" android:weightSum="1.0"&gt; &lt;SurfaceView android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.6" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>Where the <code>SurfaceView</code> is the location of your Camera Preview, now centered with 20% of the screen on all sides. If you wanted to place things over or under this preview you would obviously want to place this entire block into a <code>RelativeLayout</code> or <code>FrameLayout</code> along with other components.</p> <p>HTH!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload