2014-01-20 7 views
1

Я хочу отобразить текстовое изображение, как показано ниже. Я ищу, наконец, я получил решение с этого сайта «https://github.com/ApmeM/android-flowlayout», но я не знаю, как его использовать.Как отобразить текстовое изображение, как показано ниже.

Как я могу использовать этот вариант для отображения в качестве моего требования?

enter image description here

+0

я думаю, что это: http://stackoverflow.com/a/3496315/1809221 может помочь вам –

+0

привет, пожалуйста, см я обновил ответ, вы можете использовать FlowLayout –

+0

программно вы можете уточнить свой вопрос более правильно, как то, что ваш мотив, как это связано с выравниванием, конструированием или чем? – Balu

ответ

1

Попробуйте сделать программно

FlowLayout 
inflater = (FlowLayout) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
FlowLayout ll = (FlowLayout) inflater.inflate(R.layout.main, null); 
FlowLayout tv = (FlowLayout) inflater.inflate(R.layout.secondlayout, null); 
tv.setLayoutParams(new FlowLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 
ll.addView(tv); 
setContentView(ll); 

использовать его, как это на макете

<org.apmem.tools.layouts.FlowLayout 
         xmlns:f="http://schemas.android.com/apk/res/com.lopply.lopply" 
         xmlns:android="http://schemas.android.com/apk/res/android" 
         android:id="@+id/content3" 
         android:layout_marginTop="15dp" 
         android:layout_width="230dp" 
         android:layout_height="190dp" 
         android:layout_below="@id/title3" 
         f:horizontalSpacing="2dp" > 

         <TextView 
          android:id="@+id/content3" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/label_tip_3" 
          android:textColor="#5e5e5e" 
          android:textSize="18dp" /> 
         <TextView 
          android:id="@+id/lblFacebook" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/label_tip_3_facebook" 
          android:textColor="#c64d31" 
          android:textSize="18dp" /> 
         <TextView 
          android:id="@+id/lblAnd" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/label_tip_3_and" 
          android:textColor="#5e5e5e" 
          android:textSize="18dp" /> 
         <TextView 
          android:id="@+id/lblTwitter" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/label_tip_3_twitter" 
          android:textColor="#c64d31" 
          android:textSize="18dp" /> 
         <TextView 
          android:id="@+id/lblDot" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="@string/label_tip_3_dot" 
          android:textColor="#5e5e5e" 
          android:textSize="18dp" /> 
        </org.apmem.tools.layouts.FlowLayout> 
0
<TableLayout android:layout_width="wrap_content" 
         android:layout_height="wrap_content > 

<TableRow android:layout_width="wrap_content" 
    android:layout_height="wrap_content> <TextView 
         android:id="@+id/content3" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/label_tip_3" 
         android:textColor="#5e5e5e" 
         android:textSize="18dp" /> 
        <TextView 
         android:id="@+id/lblFacebook" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/label_tip_3_facebook" 
         android:textColor="#c64d31" 
         android:textSize="18dp" /> 
        <TextView 
         android:id="@+id/lblAnd" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/label_tip_3_and" 
         android:textColor="#5e5e5e" 
         android:textSize="18dp" /> 

</TableRow> 

<TableRow android:layout_width="wrap_content" 
    android:layout_height="wrap_content> <TextView 
         android:id="@+id/content3" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/label_tip_3" 
         android:textColor="#5e5e5e" 
         android:textSize="18dp" /> 
        <TextView 
         android:id="@+id/lblFacebook" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/label_tip_3_facebook" 
         android:textColor="#c64d31" 
         android:textSize="18dp" /> 
        <TextView 
         android:id="@+id/lblAnd" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/label_tip_3_and" 
         android:textColor="#5e5e5e" 
         android:textSize="18dp" /> 

</TableRow> 

<TableRow android:layout_width="wrap_content" 
     android:layout_height="wrap_content> <TextView 
         android:id="@+id/content3" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/label_tip_3" 
         android:textColor="#5e5e5e" 
         android:textSize="18dp" /> 
        <TextView 
         android:id="@+id/lblFacebook" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/label_tip_3_facebook" 
         android:textColor="#c64d31" 
         android:textSize="18dp" /> 
        <TextView 
         android:id="@+id/lblAnd" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="@string/label_tip_3_and" 
         android:textColor="#5e5e5e" 
         android:textSize="18dp" /> 

</TableRow> 


</TableLayout> 
+0

Я хочу отображать эти элементы programatically.i не хочу создавать в xml. – user3114723

+0

вы можете сделать то же самое, создав макет в java – raj

+0

Использовать TableLayout в месте flowlayout и использовать tablerow в родительском элементе tablelayout и добавлять элементы в tablerow – raj

0

Добавить класс FlowLayout.java (Take от андроида-FlowLayout проекта) в ур пакет. Попробовать это:

public class MainActivity extends Activity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    FlowLayout _flowLayout = new FlowLayout(this); 
    setContentView(_flowLayout); 
    TextView _tv1 = new TextView(this); 
    _tv1.setBackgroundColor(Color.RED); 
    _tv1.setText("bvfjjjjjjjjjjjjjjjv"); 
    TextView _tv2 = new TextView(this); 
    _tv2.setBackgroundColor(Color.RED); 
    _tv2.setText("bvfjjjjjjjjjjjjjjjv"); 
    TextView _tv3 = new TextView(this); 
    _tv3.setText("bvfjjjjjjjjjjjjjjjv"); 
    TextView _tv4 = new TextView(this); 
    _tv4.setText("bvfjjjjjjjjjjjjjjjv"); 
    TextView _tv5 = new TextView(this); 
    _tv5.setText("bvfjjjjjjjjjjjjjjjv"); 
    TextView _tv6 = new TextView(this); 
    _tv6.setText("bvfjjjjjjjjjjjjjjjv"); 
    _flowLayout.addView(_tv1); 
    _flowLayout.addView(_tv2); 
    _flowLayout.addView(_tv3); 
    _flowLayout.addView(_tv4); 
    _flowLayout.addView(_tv5); 
    _flowLayout.addView(_tv6); 
} 

} 
+0

привет спасибо за ответ, но я хочу, чтобы создать горизонтально, как показано на картинке выше, когда я использую ваш пост будет отображаться вертикально. – user3114723

+0

Я пробовал этот код, его работа отлично. Текстовые изображения, отображаемые горизонтально. – user543

+0

привет, я добавляю этот текст в arraylist, я хочу удалить элемент, что я касаюсь flowlayout, как я могу, я не использую какие-либо адаптеры. – user3114723

Смежные вопросы