2011-05-23 58 views
1

在我的Android应用程序中,我想要设计一个完全像Twitter布局的布局,其中图像和文本视图如何在Android中设计Twitter界面布局

请参见下面的截图

enter image description here

请帮助我。我如何设计这种布局?

更新:

忘掉背景图像和顶栏。我需要6张图片和文字浏览。在下面的图片双引号与推文(167),列表,提及,转推等,

+0

老兄,你的textView和图像是什么意思?例如 - 两个鸟和文本(推文(167))或屏幕底部? where text = #nowplaying? – Peter 2011-05-23 08:28:58

+0

@彼得:索里提。忘掉背景图片和所有。我需要这6个图像和文字浏览。谢谢你 – KillerFish 2011-05-23 08:30:45

回答

0

我敢肯定,它可以像这样创建:

image and textView mustBe on layout - so : 
    //start "a" code 
    LinearLayout oneObject ; 
    oneObject= new LinearLayout(this); 
    //need set to vertical mode 
    oneObject.setOrientation(LinearLayout.VERTICAL); 
    //it's our one object . image+text 
    next : TextView text = new TextView(this); 
    text.setText("tweets"); // or get from array 
    ///image it's can be what you want - button, layout, textView(-____-) 
    // just need set on background new image . iget button - for normal clicking ;// 
    ImageButton image = new ImageButton(this); 
    image.setImageResource(r.drawable.blabla) 
    oneObject.addView(image); 
    oneObject.addView(text); 
//also u need create 2 columns and add to this columns our object 

//for size of oneObject - use LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(curWidth/2,curHeight/6); curWidth and curHeight - its my resolution of screen. 
//end "a" code 

创建6个对象ü必须敲响它在循环: 所有代码=“A”;所以

for(int i = 0;i<6;i++) 
{ 
a/// where a all our code 
} 

希望这是帮助你..我也可以把更多的代码,其中需要一些定价

2

你想要的是相当简单的,尽管我相信有这样做,那么我更看中方式的m 即将展示给你。

对于我的应用程序,我使用了4个ImageButtons,但原理与4或6个按钮相同。

这是我的XML布局:

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout 
    android:id="@+id/actionbar_layout" 
    android:layout_width="fill_parent" 
    android:layout_height="45dip" 
    android:background="@drawable/actionbar_background" 
    android:gravity="center_vertical"> 

    <TextView 
     android:id="@+id/tekst" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="App name" 
     android:textColor="#FFFFFF" 
     android:textSize="18dp" 
     android:layout_marginLeft="5dp" 
     android:textStyle="bold"/> 

</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/button_layout" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center_vertical" 
    android:layout_below="@id/actionbar_layout"> 

    <ImageButton 
     android:id="@+id/button_schedule" 
     android:src="@drawable/schedule_icon" 
     android:scaleType="fitCenter" 
     android:layout_width="80dp" 
     android:layout_height="80dp" 
     android:layout_marginLeft="40dp" 
     android:layout_marginTop="40dp" 
     android:background="#FFFFFF" 
     /> 

    <TextView 
     android:id="@+id/text_schedule" 
     android:layout_width="80dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="40dp" 
     android:text="Rooster" 
     android:textSize="20dp" 
     android:layout_below="@id/button_schedule" 
     android:gravity="center" 
     /> 

    <ImageButton 
     android:id="@+id/button_locations" 
     android:src="@drawable/locations_icon" 
     android:scaleType="fitCenter" 
     android:layout_width="80dp" 
     android:layout_height="80dp" 
     android:layout_marginLeft="40dp" 
     android:layout_marginTop="50dp" 
     android:background="#FFFFFF"   
     android:layout_below="@id/text_schedule" 
     /> 

    <TextView 
     android:id="@+id/text_locations" 
     android:layout_width="80dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="40dp" 
     android:text="Links" 
     android:textSize="20dp" 
     android:layout_below="@id/button_locations" 
     android:gravity="center" 
     /> 

    <ImageButton 
     android:id="@+id/button_rss" 
     android:src="@drawable/rss_icon" 
     android:scaleType="fitCenter" 
     android:layout_width="80dp" 
     android:layout_height="80dp" 
     android:layout_marginLeft="40dp" 
     android:layout_marginTop="40dp" 
     android:background="#FFFFFF" 
     android:layout_toRightOf="@id/button_schedule" 
     android:layout_alignParentRight="true" 
     /> 

    <TextView 
     android:id="@+id/text_rss" 
     android:layout_width="150dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="40dp" 
     android:text="RSS" 
     android:textSize="20dp" 
     android:layout_toRightOf="@id/text_schedule" 
     android:layout_below="@id/button_rss" 
     android:layout_alignParentRight="true" 
     android:gravity="center" 
     /> 

    <ImageButton 
     android:id="@+id/button_settings" 
     android:src="@drawable/settings_icon" 
     android:scaleType="fitCenter" 
     android:layout_width="80dp" 
     android:layout_height="80dp" 
     android:layout_marginLeft="40dp" 
     android:layout_marginTop="50dp" 
     android:background="#FFFFFF" 
     android:layout_toRightOf="@id/text_locations" 
     android:layout_below="@id/text_schedule" 
     android:layout_alignParentRight="true" 
     /> 

    <TextView 
     android:id="@+id/text_settings" 
     android:layout_width="150dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="40dp" 
     android:text="Instellingen" 
     android:textSize="20dp" 
     android:layout_toRightOf="@id/text_locations" 
     android:layout_below="@id/button_settings" 
     android:layout_alignParentRight="true" 
     android:gravity="center" 
     /> 

</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/twitter_layout" 
    android:layout_width="wrap_content" 
    android:layout_height="150dp" 
    android:layout_alignParentBottom="true" 
    android:layout_below="@id/button_layout"> 

    <Gallery android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:id="@+id/gallery"   
     android:layout_gravity="bottom" 
     android:layout_alignParentBottom="true">  
    </Gallery> 
</RelativeLayout>  

我粘贴整个文件,所以你可以看到我是如何实现我的动作条。 但你需要的是第二个RelativeLayout标签。

通过使用“android:layout_toRightOf”和“android:layout_below”属性对齐按钮/文字浏览。

你的第一个按钮很简单,你对准第二个(一个在它的右边)“的Android:layout_toRightOf =” @ ID/first_button”

第三个按钮(第一个按钮的下方)可以对齐使用“android:layout_below =”@ id/first_button“

textviews也是如此,只需使用layout_toRightOf和layout_below来对齐它们即可。这些属性仅适用于RelativeLayout。

希望这会帮助你一点。