2

LinearLayout (水平) を含むアクティビティがあります。LinearLyout 内のすべての要素をマージンやパディングなしでアタッチしたいと考えています。私は多くの方法を試しましたが、役に立ちませんでした。

これは私の最後の試みです:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="0.50" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:includeFontPadding="false" >

        <TextView
            android:id="@+id/descriptionCounter"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="0dp"
            android:padding="0dp"
            android:background="@null"
            android:gravity="center_horizontal"
            android:text="@string/text_description"
            android:textColor="#33b5e5"
            android:textSize="60sp"
            android:includeFontPadding="false" />

        <TextView
            android:id="@+id/textActionCounter"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="0dp"
            android:padding="0dp"
            android:background="@null"
            android:contentDescription="@string/text_counter"
            android:gravity="center_horizontal"
            android:textColor="#33b5e5"
            android:textSize="140sp"
            android:includeFontPadding="false" />

        <TextView
            android:id="@+id/previousCounter"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_margin="0dp"
            android:padding="0dp"
            android:background="@null"
            android:contentDescription="@string/text_counter"
            android:gravity="center_horizontal"
            android:textColor="#33b5e5"
            android:textSize="60sp"
            android:includeFontPadding="false" />

    </LinearLayout>


</RelativeLayout>

どうすれば問題を解決できますか?

ありがとう!

4

4 に答える 4

0

LinearLayout で android:layout_weight プロパティを使用できます。これにより、すべてのパディングが上書きされます。

    <LinearLayout
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:weightSum="3">

 <TextView
    .
    .
    .
    android:layout_weight="1" />

<TextView
    .
    .
    .
    android:layout_weight="1" />

<TextView
    .
    .
    .
    android:layout_weight="1" />
 </LinearLayout>
于 2013-09-09T20:40:04.457 に答える
0

常に RelativeLayouts を使用してください。Linear を相対内で使用しないでください。Android でのベスト プラクティス:

http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html

たとえば、次のようなコマンドを使用します。

layout_above
layout_toRightOf
layout_alignParentTop
etc.
于 2013-09-09T20:51:18.687 に答える
0

Look in your RelativeLayout parent container and instead of:

android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"

put dimension to 0dp:

android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"
于 2016-01-31T18:32:24.600 に答える
0

values/dimens.xml ファイルでマージンを設定できます。

<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">0dp</dimen>
<dimen name="activity_vertical_margin">0dp</dimen>

于 2015-04-25T14:08:03.820 に答える