1. Are you ready for the Galaxy S20? Here is everything we know so far!

Change Styles onPressed

Discussion in 'Android Development' started by Markus Taubek, Feb 15, 2011.

  1. Markus Taubek

    Markus Taubek Newbie
    Thread Starter

    Hello,
    I have a Area with some elements: ImageView and TextView
    These elements are in an RelativLayout.
    The RelativeLayout has an onClick Listener.

    Now, I want to change all Colors on the regarding elements.
    Background of RelativLayout, src of ImageView, textColor of TextView and so on

    Is it possible to have an onPressed Listener on a RelativLayout or so.
    Or maybe somebody have an idea, how I could make an complex Element where some data will change, when it is pressed.

    Here my part:
    Code (Text):
    1.  
    2. <RelativeLayout
    3.         android:layout_width="fill_parent"
    4.         android:layout_height="50px"
    5.         android:onClick="onClickActual">
    6.             <ImageView
    7.                     android:id="@+id/lk_txt_actual"
    8.                     android:src="@drawable/home_image"
    9.                     android:layout_alignParentLeft="true"
    10.                     android:layout_width="wrap_content"
    11.                     android:layout_height="wrap_content"
    12.                     android:paddingLeft="20dp"
    13.                     android:layout_centerInParent="true" />
    14.                    
    15.             <TextView
    16.                     android:id="@+id/home_num_actual"
    17.                     android:layout_alignParentRight="true"
    18.                     android:layout_width="wrap_content"
    19.                     android:layout_height="wrap_content"
    20.                     android:text=""
    21.                     android:textColor="@color/btn_text"
    22.                     android:layout_marginRight="20dp"
    23.                     android:paddingLeft="10dp"
    24.                     android:paddingRight="10dp"
    25.                     android:paddingBottom="2dp"
    26.                     android:layout_centerVertical="true"
    27.                     style="@style/home_menu_num"
    28.                     android:visibility="invisible"
    29.                     android:background="@drawable/home_num_shape"/>
    30.            
    31.     </RelativeLayout>
    32.  
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Markus Taubek

    Markus Taubek Newbie
    Thread Starter

    The solution was View.OnTouchListener
     
Loading...

Share This Page

Loading...