0

what it is Displaying
我想要顯示如果我的數據會自動輸入其利潤率或設置爲數據what I want to display顯示左TextView的根據是正確的。如果線條填充第一的TextView和第二之間的差距應該自動最大化

幫助我儘快

我從數據庫中獲取數據,我想顯示的文字和數據自動緣至數據庫中的文本

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:weightSum="1.0" > 

<LinearLayout 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight=".5" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Large Text" 

     /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="20dp" 
     android:text="Medium Text" 
     /> 

    <TextView 
     android:id="@+id/textView3" 
     android:layout_marginTop="35dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Medium Text" 
     /> 

</LinearLayout> 

<LinearLayout 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight=".5" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/textViewq" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Large sad jhghjgh ghvfh jhgjhg jhg hghg hghjgh hg                Text" 
     /> 

    <TextView 
     android:id="@+id/textViewa" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:ellipsize="end" 
     android:text="Medium Text  hdghfhgvjh                 ds   fdhgcghgf  fghhvh  f" 
     /> 

    <TextView 
     android:id="@+id/textViewe" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Medium Text  hgfdgf hgfhgfh              f gfdgfdgf f" 
     /> 
</LinearLayout> 

+0

你的問題很混亂。你試圖達到什麼目標?現在發生了什麼 –

+0

看圖像兄我想顯示什麼,想要我想顯示 – sarvesh

+0

你想刪除兩個單詞之間的空格? –

回答

0

試試這個代碼,它套房,您的要求

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_marginTop="10dp" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="150dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Large Text" 

      /> 
     <TextView 
      android:id="@+id/textViewq" 
      android:layout_width="150dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Large sad        jhghjgh ghvfh jhgjhg jhg hghg hghjgh hg                Text" 
      /> 
     </LinearLayout> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_marginTop="10dp" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="150dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Medium Text" 
      /> 
     <TextView 
      android:id="@+id/textViewa" 
      android:layout_width="150dp" 
      android:layout_height="wrap_content" 
      android:ellipsize="end" 
      android:layout_weight="1" 
      android:text="Medium Text  hdghfhgvjh                 ds   fdhgcghgf  fghhvh  f" 
      /> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_marginTop="10dp" 
     android:layout_height="wrap_content"> 
     <TextView 
      android:id="@+id/textView3" 
      android:layout_width="150dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Medium Text" 
      /> 
     <TextView 
      android:id="@+id/textViewe" 
      android:layout_width="150dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Medium Text  hgfdgf hgfhgfh              f gfdgfdgf f" 
      /> 

    </LinearLayout> 

    </LinearLayout> 
2

enter image description here

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


    <TableRow 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:text="Large Text" 

      /> 

     <TextView 
      android:id="@+id/textViewq" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:text="Large sad jhghjgh ghvfh jhgjhg jhg hghg hghjgh hg                Text" /> 
    </TableRow> 

    <TableRow 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:text="Medium Text" /> 

     <TextView 
      android:id="@+id/textViewa" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:ellipsize="end" 
      android:text="Medium Text  hdghfhgvjh                 ds   fdhgcghgf  fghhvh  f" /> 
    </TableRow> 

    <TableRow 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <TextView 
      android:id="@+id/textView3" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:text="Medium Text" /> 

     <TextView 
      android:id="@+id/textViewe" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Medium Text  hgfdgf hgfhgfh              f gfdgfdgf f" /> 
    </TableRow> 
</LinearLayout> 
+0

@sarvesh如果有幫助,那麼你可以打勾標記。快樂編碼:) –

0

留兩個TextView的在LinearLayout中。並設置像這樣的Linearlayout重心:

android:gravity="center" 

對三個線性佈局做同樣的事情。

0

使用此部分代碼作爲您的基本佈局結構。它將保持您的物品完美的水平對齊。

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:weightSum="1.0" 
    > 

    <TextView 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:text="Text on Right" 
     android:layout_weight="0.5" 
     /> 
    <TextView 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:text="Text on Left" 
     android:layout_weight="0.5" 
     /> 
</LinearLayout> 

但是,我建議你使用RecyclerView。 Check this link。 您只需要一個xml佈局,並將其添加爲您的ITEM到您的父級佈局。因此,如果數據庫中有50,60,70或3個項目,則無關緊要,您的佈局將自動回收。沒有麻煩。

希望它有幫助。乾杯!

編輯: 我給出的佈局代碼應該在一個linearLayout裏面,它必須是VERTICAL。

相關問題