REQUEST v4 Clickable ImageView nested inside RelativeLayout

blackestflag

Well-known member
Joined
Oct 19, 2022
Messages
498
Awards
4
Offline
Hey folks, just having some struggles getting some menu items to be "clickable" in Smarters v4
Have tried several combinations of android:clickable="true", but not having any success

As usual, I'm sure it's something pretty simple, that I should already know... lol

1712243423072.png

I've attached the dashboard.xml, and a snippet of the code in question
XML:
                <RelativeLayout android:background="@drawable/tbf_button1_new"
                                android:layout_width="@dimen/_30sdp"
                                android:layout_height="@dimen/_30sdp"
                                android:focusable="true"
                                android:layout_marginBottom="@dimen/_6sdp" >

                    <ImageView
                        android:id="@id/iv_radio"
                        android:layout_width="@dimen/_30sdp"
                        android:layout_height="@dimen/_30sdp"
                        android:layout_centerInParent="true"
                        android:clickable="true"
                        android:padding="@dimen/_9sdp"
                        android:src="@drawable/hp_radio"
                        android:tag="7" />
                    <TextView android:textSize="@dimen/_10sdp"
                                      android:textColor="#ffffffff"
                                      android:visibility="gone"
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:text="Radio"
                                      android:layout_centerVertical="true"
                                      android:fontFamily="@font/corsa"
                                      android:layout_marginStart="@dimen/_5sdp"
                                      android:layout_toEndOf="@id/iv_radio"/>
                </RelativeLayout>


Any advice, as always; is greatly appreciated

Full dashboard XML layout file
 
Last edited:

credibletv

Well-known member
Joined
Jul 31, 2022
Messages
143
Awards
3
Offline
Use the code below and check


XML:
<RelativeLayout android:background="@drawable/tbf_button1_new"
                                android:layout_width="@dimen/_30sdp"
                                android:layout_height="@dimen/_30sdp"
                                android:layout_marginBottom="@dimen/_6sdp" >

                    <ImageView
                        android:id="@id/iv_radio"
                        android:layout_width="@dimen/_30sdp"
                        android:layout_height="@dimen/_30sdp"
                        android:layout_centerInParent="true"
                        android:focusable="true"
                        android:padding="@dimen/_9sdp"
                        android:src="@drawable/hp_radio"
                        android:tag="7" />
                    <TextView android:textSize="@dimen/_10sdp"
                                      android:textColor="#ffffffff"
                                      android:visibility="gone"
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:text="Radio"
                                      android:layout_centerVertical="true"
                                      android:fontFamily="@font/corsa"
                                      android:layout_marginStart="@dimen/_5sdp"
                                      android:layout_toEndOf="@id/iv_radio"/>
                </RelativeLayout>
 

G-man

Well-known member
Joined
Apr 16, 2021
Messages
1,908
Awards
4
Offline
only thing i can see that is different is this ;-
Screenshot 2024-04-04 161245.jpg

or this :-
<RelativeLayout android:background="@drawable/tbf_button1_new"
android:layout_width="@dimen/_30sdp"
android:layout_height="@dimen/_30sdp"
android:focusable="true"
android:layout_marginBottom="@dimen/_6sdp" >
<ImageView
android:id="@id/iv_radio"
android:layout_width="@dimen/_30sdp"
android:layout_height="@dimen/_30sdp"
android:layout_centerInParent="true"
android:focusable="true"
android:clickable="true"
android:padding="@dimen/_9sdp"
android:src="@drawable/hp_radio"
android:tag="7" />
<TextView android:textSize="@dimen/_10sdp"
android:textColor="#ffffffff"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Radio"
android:layout_centerVertical="true"
android:fontFamily="@font/corsa"
android:layout_marginStart="@dimen/_5sdp"
android:layout_toEndOf="@id/iv_radio"/>

</RelativeLayout>
 

blackestflag

Well-known member
Joined
Oct 19, 2022
Messages
498
Awards
4
Offline
Use the code below and check


XML:
<RelativeLayout android:background="@drawable/tbf_button1_new"
                                android:layout_width="@dimen/_30sdp"
                                android:layout_height="@dimen/_30sdp"
                                android:layout_marginBottom="@dimen/_6sdp" >

                    <ImageView
                        android:id="@id/iv_radio"
                        android:layout_width="@dimen/_30sdp"
                        android:layout_height="@dimen/_30sdp"
                        android:layout_centerInParent="true"
                        android:focusable="true"
                        android:padding="@dimen/_9sdp"
                        android:src="@drawable/hp_radio"
                        android:tag="7" />
                    <TextView android:textSize="@dimen/_10sdp"
                                      android:textColor="#ffffffff"
                                      android:visibility="gone"
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:text="Radio"
                                      android:layout_centerVertical="true"
                                      android:fontFamily="@font/corsa"
                                      android:layout_marginStart="@dimen/_5sdp"
                                      android:layout_toEndOf="@id/iv_radio"/>
                </RelativeLayout>
That works.. BUT.... the layout is then ignoring my android:background="@drawable/tbf_button1_new" in the RLayout which has onFocus and pressed states
 

credibletv

Well-known member
Joined
Jul 31, 2022
Messages
143
Awards
3
Offline
That works.. BUT.... the layout is then ignoring my android:background="@drawable/tbf_button1_new" in the RLayout which has onFocus and pressed states
The code you shared is bind to id @id/iv_radio which must be defined as image view in smalis in dashboard activities Either you need to change all in smalis to relative layout and define the id to your relative layout if you change the id to relative layout without changing in smalis ur app will crash when logs in or when u reach the dashboard
 

blackestflag

Well-known member
Joined
Oct 19, 2022
Messages
498
Awards
4
Offline
The code you shared is bind to id @id/iv_radio which must be defined as image view in smalis in dashboard activities Either you need to change all in smalis to relative layout and define the id to your relative layout if you change the id to relative layout without changing in smalis ur app will crash when logs in or when u reach the dashboard
Sorry, I don't understand.
The app isn't crashing at this point.
I just wanted to swap out the images from a zoom effect on the radio icon, to a outlined stroke effect

It seems I can't have both, and I understand the limit here is my knowledge, or lack thereof :(
 

credibletv

Well-known member
Joined
Jul 31, 2022
Messages
143
Awards
3
Offline
Sorry, I don't understand.
The app isn't crashing at this point.
I just wanted to swap out the images from a zoom effect on the radio icon, to a outlined stroke effect

It seems I can't have both, and I understand the limit here is my knowledge, or lack thereof :(

You button functions bind to this ID iv_radio which is defined as ImageView in Smalis may be in NewDashboardActivity or similar name

If you want the relative layout to work as button you need to swap the ID to relative layout but to do so you need to change all the SmaliCode which define this id on ImageView.


If you swap the id before editing the smali code then your app will crash

at the moment your Code defines

<imageView
android:id=@id/iv_radio" is the button

if you define focusable on relative layout ti will move to layout but button wont work
if you swap id from imageview to relative layout without editing smalis app will crash.
best way I can suggest you is

define the background in Imageview via XML file add focus and non focus effect upon selection bet example you will get is login button files copy from there and define your images in it

1712246288660.png
 

blackestflag

Well-known member
Joined
Oct 19, 2022
Messages
498
Awards
4
Offline
You button functions bind to this ID iv_radio which is defined as ImageView in Smalis may be in NewDashboardActivity or similar name

If you want the relative layout to work as button you need to swap the ID to relative layout but to do so you need to change all the SmaliCode which define this id on ImageView.


If you swap the id before editing the smali code then your app will crash

at the moment your Code defines

<imageView
android:id=@id/iv_radio" is the button

if you define focusable on relative layout ti will move to layout but button wont work
if you swap id from imageview to relative layout without editing smalis app will crash.
best way I can suggest you is

define the background in Imageview via XML file add focus and non focus effect upon selection bet example you will get is login button files copy from there and define your images in it

View attachment 9498
Apologies, have been tied up with other projects recently

THANK YOU !
Alright, so... that worked, adding the android:background="@drawable/tbf_button1" to the ImageView.

BUT, now... I cannot sort out the ZOOM/ANIMATE that happens onFocus
It's cutting off the edges of the button

Does anyone know how to disable this ?
Or expand the RelativeLayout to accomodate the increased size, onFocus and Pressed ?
I looked through the onClickListener entries in smali, but couldn't make heads or tails of it.
I'm sure there is a scale factor there somewhere, lol

I certainly appreciate you guys helping me through learning the nuances of all this :)
 

Attachments

  • 041124102113.png
    041124102113.png
    113.7 KB · Views: 11

credibletv

Well-known member
Joined
Jul 31, 2022
Messages
143
Awards
3
Offline
Apologies, have been tied up with other projects recently

THANK YOU !
Alright, so... that worked, adding the android:background="@drawable/tbf_button1" to the ImageView.

BUT, now... I cannot sort out the ZOOM/ANIMATE that happens onFocus
It's cutting off the edges of the button

Does anyone know how to disable this ?
Or expand the RelativeLayout to accomodate the increased size, onFocus and Pressed ?
I looked through the onClickListener entries in smali, but couldn't make heads or tails of it.
I'm sure there is a scale factor there somewhere, lol

I certainly appreciate you guys helping me through learning the nuances of all this :)
You need to define img also via XML file and add focus selected variations that will disable the zooming effect
 

FelixSchrodinger

Well-known member
Joined
Jun 17, 2022
Messages
256
Awards
3
Offline
Apologies, have been tied up with other projects recently

THANK YOU !
Alright, so... that worked, adding the android:background="@drawable/tbf_button1" to the ImageView.

BUT, now... I cannot sort out the ZOOM/ANIMATE that happens onFocus
It's cutting off the edges of the button

Does anyone know how to disable this ?
Or expand the RelativeLayout to accomodate the increased size, onFocus and Pressed ?
I looked through the onClickListener entries in smali, but couldn't make heads or tails of it.
I'm sure there is a scale factor there somewhere, lol

I certainly appreciate you guys helping me through learning the nuances of all this :)

To stop the zoom, can search for 0x3fc00000 (1.5) and change to 0x3f800000 (1.0) in one of the NewDashboardActivity smali files

Or to stop the image from clipping when it zooms, if you add

android:clipChildren="false"
android:clipToPadding="false"

To each parent view. Then the view where the buttons are, add

android:clipToPadding="false"
android:elevation="50.0dip"

The elevations only to bring the view to the front, above everything else.
 

blackestflag

Well-known member
Joined
Oct 19, 2022
Messages
498
Awards
4
Offline
To stop the zoom, can search for 0x3fc00000 (1.5) and change to 0x3f800000 (1.0) in one of the NewDashboardActivity smali files

Or to stop the image from clipping when it zooms, if you add

android:clipChildren="false"
android:clipToPadding="false"

To each parent view. Then the view where the buttons are, add

android:clipToPadding="false"
android:elevation="50.0dip"

The elevations only to bring the view to the front, above everything else.
Finally had a chance to revisit this, and I will say straight up... THANK YOU FELIX !
clipChildren was exactly what I was looking for

1714054679825.png
 
Top