0

こんにちは、私はアンドロイドが初めてで、次の問題があります(画像を参照)。

ここに画像の説明を入力

上に見られるように、画像はテキスト ビューに重なっています。誰でも私がそれを修正するのを手伝ってくれますか?

次のコードを使用しています。

<EditText
            android:id="@+id/outlet_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="170dp"            
            android:hint="@string/outlet_id_text"
            android:inputType="textAutoComplete" />

        <ImageView
            android:id="@+id/search_button"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:layout_gravity="center"
            android:layout_marginTop="-48dp"
            android:adjustViewBounds="true"
            android:contentDescription="@string/cd_search_icon"
            android:src="@drawable/search_icon" />





<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background"
    android:orientation="vertical" >

    <LinearLayout       
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentRight="true"
        android:background="@color/background"
        android:orientation="vertical" >

        <org.fluturasymphony.recommendation.ScrollingTextView

        android:text="Really Long Scrolling Text Goes Here.... ..... ............ .... ...."

        android:singleLine="true"

        android:ellipsize="marquee"

        android:marqueeRepeatLimit="marquee_forever"

        android:scrollHorizontally="true"

        android:id="@+id/TextView03"

        android:padding="25dip" 

        android:layout_width="wrap_content" 

        android:layout_height="wrap_content" />

        <EditText
            android:id="@+id/outlet_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="170dp"            
            android:hint="@string/outlet_id_text"
            android:inputType="textAutoComplete" />

        <ImageView
            android:id="@+id/search_button"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:layout_gravity="center"
            android:layout_marginTop="-48dp"
            android:adjustViewBounds="true"
            android:contentDescription="@string/cd_search_icon"
            android:src="@drawable/search_icon" />

        <Button
            android:id="@+id/view_stores_on_map"
            android:layout_width="221dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="76dp"
            android:onClick="showStoreList"
            android:text="@string/view_stores_on_map" />

    <Button
        android:id="@+id/view_stores"

        android:layout_width="221dp"
        android:layout_height="wrap_content"


        android:layout_gravity="center"
        android:layout_marginTop="38dp"
        android:onClick="showStoreList"
        android:text="View List Of Stores" />

    </LinearLayout>


</RelativeLayout>
4

6 に答える 6

2

次の行も使用できます。または、行アイテムとして使用する場合は、これら 2 つのアイテムの向きを単独で使用できます。

  <EditText
            android:layout_centerInParent="true"
            android:id="@+id/outlet_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="170dp"            
            android:hint="outlet_id_text"
            android:drawableRight="@drawable/ic_launcher"
            android:inputType="textAutoComplete" />
于 2013-01-02T07:00:57.267 に答える
2

相対レイアウトを使用してデザインを管理できますが (ただし、使用は検索画像を表示するだけなので、この要件のために追加のビューを追加する必要はないことに注意してください)。これを行う最も簡単な方法は次のとおりです。

android:drawableTopEditTextのプロパティを使用します。

<EditText
    ...     
    android:drawableTop="@drawable/ic_action_search" />

を削除します。<ImageView>

その他のオプションは android:drawableRight、 、android:drawableLeftandroid:drawableBottomおよびその他です。

于 2013-01-02T07:01:19.993 に答える
1

これを試して :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentRight="true"
        android:background="@color/background"
        android:orientation="vertical" >

        <org.fluturasymphony.recommendation.ScrollingTextView
            android:id="@+id/TextView03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:marqueeRepeatLimit="marquee_forever"
            android:padding="25dip"
            android:scrollHorizontally="true"
            android:singleLine="true"
            android:text="Really Long Scrolling Text Goes Here.... ..... ............ .... ...." />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="170dp"
            android:background="@color/background"
            android:orientation="horizontal" >

            <EditText
                android:id="@+id/outlet_id"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:hint="@string/outlet_id_text"
                android:inputType="textAutoComplete" />

            <ImageView
                android:id="@+id/search_button"
                android:layout_width="32dp"
                android:layout_height="32dp"
                android:adjustViewBounds="true"
                android:contentDescription="@string/cd_search_icon"
                android:src="@drawable/search_icon" />
        </LinearLayout>

        <Button
            android:id="@+id/view_stores_on_map"
            android:layout_width="221dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="76dp"
            android:onClick="showStoreList"
            android:text="@string/view_stores_on_map" />

        <Button
            android:id="@+id/view_stores"
            android:layout_width="221dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="38dp"
            android:onClick="showStoreList"
            android:text="View List Of Stores" />
    </LinearLayout>

</RelativeLayout>

それはあなたの問題を解決します。

ありがとう。

于 2013-01-02T07:17:55.473 に答える
1

これを試してみてください。うまくいくことを願っています。

<LinearLayout android:layout_width="fill_parent"
         android:layout_height="wrap_content" android:layout_marginTop="40dp">
    <EditText
            android:id="@+id/outlet_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/outlet_id_text"
            android:inputType="textAutoComplete" />

        <ImageView
            android:id="@+id/search_button"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:adjustViewBounds="true"
            android:contentDescription="@string/cd_search_icon"
            android:src="@drawable/ic_launcher" />
</LinearLayout>
于 2013-01-02T07:02:29.377 に答える
1

View でガジェットを配置するには、android:layout_below="@+id/search_button" 属性を使用します。

<EditText
        android:id="@+id/outlet_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="10dp" 
        android:layout_below="@+id/search_button"           
        android:hint="@string/outlet_id_text"
        android:inputType="textAutoComplete" />

    <ImageView
        android:id="@+id/search_button"
        android:layout_width="32dp"
        android:layout_height="32dp"
        android:layout_gravity="center"
        android:layout_marginTop="170dp"
        android:adjustViewBounds="true"
        android:contentDescription="@string/cd_search_icon"
        android:src="@drawable/search_icon" />
于 2013-01-02T07:07:35.983 に答える
1

上に移動させたい場合はandroid:layout_marginTop、画像ビューをより負の値に変更します。下げる必要がある場合は、反対のことを行います。

 <ImageView
    android:id="@+id/search_button"
    android:layout_width="32dp"
    android:layout_height="32dp"
    android:layout_gravity="center"
    android:layout_marginTop="-48dp" <!-- add more  -ve value to move up, decrease to move down -->
    android:adjustViewBounds="true"
    android:contentDescription="@string/cd_search_icon"
    android:src="@drawable/search_icon" />
于 2013-01-02T06:57:50.837 に答える