9

私はアンドロイド開発に不慣れで、どうすれば2つのTextViewの間にスペースを追加できるのか疑問に思っていましたか? どんな助けでも大歓迎です。

今まで書いたコード

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/lbl_group_coworkers"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Coworkers" />

    <TextView 
        android:id="@id/lbl_group_"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Family"/>



</LinearLayout>
4

11 に答える 11

17

このように android:layout_marginTop="value" を使用できます

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/lbl_group_coworkers"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Coworkers" />

        <TextView 
            android:id="@id/lbl_group_"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:text="Family"/>
    </LinearLayout>
于 2013-09-11T11:46:11.713 に答える
6

2 つのテキストビューの間にマージンを設定できます。2番目のテキストビューに上マージンを追加します

このような

 <TextView 
    android:id="@id/lbl_group_"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"
    android:text="Family"/>
于 2013-09-11T11:45:49.367 に答える
3

に置き換え<LinearLayout> </LinearLayout><RelativeLayout> </RelativeLayout> から、グラフィカルなレイアウトに入り、好きなようにスペースを調整してください。

于 2013-09-11T11:49:29.943 に答える
1

android:layout_marginRight="..."最初の textView に追加します

于 2013-09-11T11:44:24.130 に答える
1

マージンを追加してみてください

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/lbl_group_coworkers"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Coworkers" 
    android:layout_margin="10dp"/>

<TextView 

    android:id="@+id/lbl_group"
    android:layout_margin="10dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Family"/>

</LinearLayout>
于 2013-09-11T11:44:36.957 に答える
1

使用できます

android:layout_margin="5dp"

また

android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"

しかし、そのような質問をさらに多くする前に、Android dev ガイド ( http://developer.android.com/guide/components/fundamentals.html )を読むことをお勧めします。

頑張って開発を楽しんでください...

于 2013-09-11T11:44:49.880 に答える
1

マージンを追加する 左 右 上 下

 android:layout_marginLeft="10dp"
于 2013-09-11T11:42:35.870 に答える
-1
  <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical" android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="@drawable/custom_border"
  >
  <TextView
      android:text="@string/textView_reference_number"
      style="@style/CustomTextView"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/textView_refernce_number_label"
      />
   <TextView
      android:text="Reference Number Value"
      style="@style/CustomTextView"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/textView_refernce_number"
      android:layout_marginTop="10dp"/>   
 </LinearLayout>

android:layout_marginTop XML 属性を使用して、このビューの上部に余分なスペースを指定します。したがって、2 番目の textView の android:layout_marginTop="10dp" は、それと上のビューの間に 10 dp のスペースを指定しています。@UDI 同じhttps://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.htmlの詳細については、以下のリンクを参照してください。

于 2016-11-23T11:54:26.803 に答える