2011-01-06 7 views
3

初心者のおしゃべりは、アンドロイドになると数日間は正しく働いていますが、すべての検索が終わった後でも、私は困惑しており、誰も助けてくれないようです。私はこれまでのところ、これを持っている:LinearLayout - テキストをアイコンの右側に表示するにはどうすればいいですか?

http://img263.imageshack.us/i/sellscreen.jpg

は、どのように私は、その下ではなく、各アイコンのほかにするために、テキストを移動することができますか?ギャラリーを望んでも移動されません。ここで私が持っているコードです:私のコードの

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

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scroller" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fillViewport="true" > 

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

    <Gallery xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gallery" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"/> 

    <ImageView 
    android:id="@+id/test_image" 
    android:src="@drawable/icon" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 

    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="The offcial UK driving theory test application. Over 190 questions." 
    /> 

    <ImageView 
    android:id="@+id/test_image" 
    android:src="@drawable/icon" 

    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 

    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="The offcial UK driving theory test application. Over 190 questions."/> 

    <ImageView 
    android:id="@+id/test_image" 
    android:src="@drawable/icon" 

    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 

    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="The offcial UK driving theory test application. Over 190 questions."/> 

    <ImageView 
    android:id="@+id/test_image" 
    android:src="@drawable/icon" 

    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 

    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="The offcial UK driving theory test application. Over 190 questions."/> 

    <ImageView 
    android:id="@+id/test_image" 
    android:src="@drawable/icon" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    /> 

    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="The offcial UK driving theory test application. Over 190 questions." 
     /> 

    </LinearLayout> 

</ScrollView> 

上半分が何らかの理由で表示されていないようですが、それは、リニアレイアウトのちょうどオープニングです。 私は何かを助けることができる人に永遠に感謝しています。本当にそれによって強調されて取得します。前もって感謝します!!

答えて

3

あなたはそれ、これは非常に簡単ですので、あなたは、アンドロイド知っていた誰も聞いていなかったこともかなり明確だ

<LinearLayout 
android:orientation="horizontal" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"> 
    <ImageView 
    android:id="@+id/test_image" 
    android:src="@drawable/icon" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/> 

    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="The offcial UK driving theory test application. Over 190 questions." 
    /> 
</LinearLayout> 

のLinearLayoutでImageViewの各/ TextViewのペアをラップする必要があります。

+0

私は2つのアンドロイドのフォーラムに投稿して以来、人々はちょうど怠惰だと思う。ああ、それは2番目に修正されたときに私の頭脳をラッキングのためにも、非常に非常にありがとう! –

+1

@RED_:確かに。しかしまた、@ Mayraの答えを検討してください。私はこの特定のケースで相対レイアウトを使用する方が効率的であるとは確信していませんが、一般的には深くネストされた線形レイアウトよりも相対レイアウトを使用する方が良い方法です。 – Falmarri

+0

ええ、RelativeLayoutsは現時点で私の地獄を混乱させる意味があります。どのように正しい場所にすべてを取得することが主なものですが、私はそれを持っているより多く私はそれを拾うだろうと確信しています。 –

1

あなたはAndroidのレイアウトチュートリアルを読んだことがありますか?デベロッパーサイトのたくさんのもの、declaring layoutcommon layout objectshello viewsチュートリアルなど。

目的に応じて、これを達成するにはいくつかの方法があります。

スクロールしたいサイズが不明なアイテムのリストですか? ListViewを使用してください。あなたはあなたのものを並べて、ListViewにカスタムレイアウトを提供することができます。

あなたには有限のものがありますか? RelativeLayoutを使用してください。それぞれTextViewに上記のレイアウトの下に、ImageViewの右側にそれぞれTextViewのレイアウトを教えてください。

LinearLayoutsの1つの縦と横の束を入れても、それは達成することができますが、それはRelativeLayoutを使用するよりも効率が悪いです。

+0

'しかし、それはRelativeLayout'を使うよりも効率が悪いです。私は同意していないが、3つのレイアウトのネストはそれほど高価に見えない。 – Falmarri

+1

電源が限られていて電池が使い果たされているデバイスを扱う場合、なぜ効率を上げるのが簡単なのか、なぜゆっくりとしたいのですか?それは数サイクルを節約するために複雑で複雑なものだったが、相対レイアウトを使用することは決して難しいことではない。 –

+0

それは間違いなく効率が悪いですが、もし私がどれくらい分かっていなければ。 Commonswareには大きな記事がありましたが、私は今見つけることができませんが、この投稿はなぜの基本的なアイデアを示しています:http://developer.android.com/resources/articles/layout-tricks-efficiency.html –

関連する問題