开发者

Again ImageButton issues

开发者 https://www.devze.com 2023-02-04 17:47 出处:网络
Thanks at all for all your help for now.I have another little issues This is a portion of my layout which give me some problems:

Thanks at all for all your help for now.I have another little issues

This is a portion of my layout which give me some problems:

<RelativeLayout android:id="@+id/card_address_layout"开发者_开发知识库
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="visible"
            >
                 <TextView
                    style="@style/card_field"
                    android:id="@+id/card_indirizzo"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_gravity="left|center_vertical"                     
                    android:layout_marginTop="8dp"                 
                    android:maxLength="35"
                    android:ellipsize="marquee"

                 /> 

                 <ImageButton 
                    android:id="@+id/card_address_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right|center_vertical"
                    android:layout_toRightOf="@id/card_indirizzo"
                    android:src="@drawable/map_selector"
                    android:onClick="startMap"
                    android:padding="0dp"  />

         </RelativeLayout>

The image button src is a selector, in this case this one:

 <selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item android:state_pressed="true" android:drawable="@drawable/map_b" /> <!-- pressed -->
 <item android:drawable="@drawable/map_a" />                 <!-- default -->

This is the result and I really don't understand why, why the image button has padding??!!!

Again ImageButton issues

Help meeeee!

This is the FULL xml:

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

    <HorizontalScrollView android:id="@+id/card_images_horizontalscroll"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:scrollbars="none"
        android:visibility="invisible"


        >


            <LinearLayout android:id="@+id/card_images_layout"
                            android:orientation="horizontal"
                            android:layout_width="wrap_content"
                            android:layout_height="80dp"
                            android:layout_marginRight="4dp"
            >




            </LinearLayout>




    </HorizontalScrollView>

    <TextView
        android:id="@+id/card_images_footer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:background="@drawable/click_it"
     />





<ScrollView android:id="@+id/card_data_verticalscroll"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"

            >

        <LinearLayout android:id="@+id/main_vertical_scroll_layout"
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
        >


            <TextView
                style="@style/card_title"
                android:id="@+id/card_name"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:layout_weight="1"
            />  
            <TextView
                style="@style/card_category"
                android:id="@+id/card_categoria"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:layout_marginBottom="30dp"

             /> 

         <RelativeLayout android:id="@+id/card_address_layout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="visible"
            >
                 <TextView
                    style="@style/card_field"
                    android:id="@+id/card_indirizzo"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_gravity="left|center_vertical"                     
                    android:layout_marginTop="8dp"                 
                    android:maxLength="35"
                    android:ellipsize="marquee"

                 /> 

                 <ImageButton 
                    android:id="@+id/card_address_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right|center_vertical"
                    android:layout_toRightOf="@id/card_indirizzo"
                    android:src="@drawable/map_selector"
                    android:onClick="startMap"
                    android:padding="0dp"  />

         </RelativeLayout>

         <RelativeLayout android:id="@+id/card_phone_layout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone"
            >

                <TextView
                         style="@style/card_field"
                        android:id="@+id/card_telefono"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:maxLength="35"
                        android:ellipsize="marquee"
                        android:layout_gravity="center_vertical"
                        android:layout_marginTop="8dp"
                     /> 

                <ImageButton android:text="call"
                        android:id="@+id/card_telefono_button"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_gravity="right|center_vertical"
                        android:src="@drawable/call_selector"
                        android:onClick="startCall"

                    />
        </RelativeLayout>

        <RelativeLayout android:id="@+id/card_mail_layout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone"
            >

                <TextView
                        style="@style/card_field"
                        android:id="@+id/card_mail"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:maxLength="35"
                        android:ellipsize="marquee"
                        android:layout_gravity="center_vertical"
                        android:layout_marginTop="8dp"
                     /> 
                <ImageButton android:text="mail"
                        android:id="@+id/card_mail_button"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_gravity="right|center_vertical"
                        android:onClick="startMailClient"
                        android:src="@drawable/mail_selector"

                    />
        </RelativeLayout>


         <RelativeLayout android:id="@+id/card_www_layout"
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone"
            >

                <TextView
                        style="@style/card_field"
                        android:id="@+id/card_www"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:maxLength="35"
                        android:ellipsize="marquee"
                        android:layout_gravity="center_vertical"
                        android:layout_marginTop="8dp"
                     /> 
                <ImageButton android:text="www"
                        android:id="@+id/card_www_button"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_gravity="right|center_vertical"
                        android:onClick="startDefaultBrowser"
                        android:src="@drawable/www_selector"
                    />
        </RelativeLayout>




        <TextView
            style="@style/card_description"
            android:id="@+id/card_descrizione"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="false"
            android:layout_marginTop="30dp"
         /> 

         </LinearLayout>

</ScrollView>


pedro , just change android:src="@drawable/map_selector" to android:background="@drawable/map_selector"

& you are done!

0

精彩评论

暂无评论...
验证码 换一张
取 消