1

私は3つのテキストブロックとスケッチに示されているようにレイアウトに収めたい画像を持っています。 (1秒間赤い線を無視してください) enter image description here
(私は品質がひどいと知っています。誰かがオススメx/linux用のまともな(オープン)グラフィックエディタをお勧めできるなら、 !テキストブロックと画像の位置付け

  • 相対レイアウト:))

    私の考えでは、このような問題に取り組むことでした。

  • 最初のテキストブロックを基準にして2番目のテキストブロックを配置します。

例えば:

android:layout_below=text1 
android:layout_ (make it "float" to screen's right edge - not sure how to do that, yet. 
  • 第1及び第2ブロックに対する第三のテキストブロック。

例えば:

android:layout_below=text2 
android:layout_alignLeft = text1 

[OK]をクリックします。いいえ、画像に出ましょう。それは任意のサイズですので、私はそれを適合させることができるいくつかのアライメントについて考えました。スケッチから赤い線を見ることが分かっていれば、それに応じてイメージを整列させます。

android:layout_alignTop = text2 
android:layout_alignBottom = text2 
android:layout_alignLeft = text1 

は、しかし、私はレイアウトを行う上で非常に良いではないと私はこのように、多かれ少なかれ、画面上の周りのノックコンテンツの4枚を、それを実装しようとしたが、私は位置にそれらのすべてをやったことがなかったとき。

私が達成できる最も近いのはこれでしたが、そこにはハードコーディングされた制限の使用が嫌いです。私はそれがスーパーフレキシブルではないことに恐れています。
私はイメージの表示サイズを幾分制限しなければなりませんでしたが、囲まれたテキストブロックを望んでいました。ドロイドは自分でサイズを把握するのに十分なほどスマートです。

<TextView 
    android:id="@+id/text1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="10dip" 
    android:text="text1" /> 

<ImageView 
    android:id="image" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="text1" 
    android:layout_marginRight="7dip" 
    android:layout_marginTop="5dip" 
    android:adjustViewBounds="true" 
    android:maxHeight="150sp" 
    android:maxWidth="150sp" 
    android:src="srcFile" /> 

<TextView 
    android:layout_marginTop="5dip" 
    android:id="text2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignTop="image" 
    android:layout_below="text1" 
    android:layout_toRightOf="image" 
    android:text="text2" /> 

<TextView 
    android:id="text3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="image" 
    android:layout_marginTop="10dip" 
    android:text="text3" /> 

だから私はあなたが私のアプローチを考えると何かがあるかどう私は改善できるだけでなく、どのように実際にそれを実装するために何を聞きたいのですが。

編集: だから、私はそれが十分に柔軟ではありません怖いので、私はこのコードの一部をドロップする可能性が解決策を見つけるしたいと思います:

android:maxHeight="150sp" 
android:maxWidth="150sp" 

答えて

1

イメージの比率を維持し、コードなしでサイズを調整することは可能です。単純に線形レイアウトし、それに応じて

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

    <LinearLayout 
     android:id="@+id/ll" 
     android:layout_below="@+id/text1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:weightSum="2" 
     android:orientation="horizontal" > 

     <ImageView 
      android:id="@+id/image" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="11" 
      android:adjustViewBounds="true" 
      android:src="srcFile" /> 

     <TextView 
      android:id="@+id/text2" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="text2" /> 
    </LinearLayout> 

    <TextView 
     android:id="@+id/text3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/ll" 
     android:text="text3" /> 
+0

。魅力のように働く!ありがとうございました。 – yoshi

0

簡単な解決策は、おそらくです最高の。垂直または水平に設定向きでlinear layoutを使用:

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    > 
    <TextView 
     android:id="@+id/text1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="10dip" 
     android:text="text1" /> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="horizontal"> 
     <ImageView 
      android:id="image" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:layout_marginRight="7dip" 
      android:layout_marginTop="5dip" 
      android:adjustViewBounds="true" 
      android:maxHeight="150sp" 
      android:maxWidth="150sp" 
      android:src="srcFile" /> 

     <TextView 
      android:layout_marginTop="5dip" 
      android:id="text2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="text2" /> 

    </LinearLayout> 
    <TextView 
     android:id="text3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="10dip" 
     android:text="text3" /> 
</LinearLayout> 
+0

重量ビューを使用するだけでなく、あります、ハードコードのmaxHeight/-width o.O – yoshi

+0

、あなたは画面サイズ –

0

それは

android:id="@+id/image" 

及び第二のテキストに

android:layout_toRightOf="@+id/image" 
android:layout_below="@+id/text1" 

を使用するように

修復画像IDに十分であろう

第三のみ

android:layout_below="@+id/text2" 

LinearLayoutsについては

...私はあまりにも彼らのように、彼らは簡単ですが、遅い - あまり利用していません。

+0

私は私は私の質問を編集すると思うを取得するために、表示オブジェクトを使用することにより、実行時にそれを行うことができます。ハードコードされた値でイメージのサイズを変更することに依存しないソリューションが欲しい。このソリューションは、画像サイズに手動で制限を設定した場合にのみ機能します。 :C – yoshi

+0

**画像の比率を維持したり、コードなしでサイズを調整することはできません。 – Gangnus

+0

質問に答えた、エラーが見つかりました - 答えをマークしてください。そして、それほど変わった答えは別のものになるでしょう。確かに – Gangnus