ImageButton onClick not called in RelativeLayout in a Fragment using a transparent ActionBar

Bobbelinio

any ideas why my ImageButton isn't working in my Fragment? The ImageButton contains a Drawable and is transparent. When I place it in my RelativeLayout below, its working...

<RelativeLayout
android:id="@+id/rl_newsdet_root"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/bg"
android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
    android:id="@+id/tv_newsdet_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="@color/white"
    android:layout_marginTop="7dp"
    android:textSize="20sp"
    android:layout_centerHorizontal="true"
    />

<ImageButton
    android:id="@+id/btn_newsdet_back"
    android:layout_marginLeft="10dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:src="@drawable/bt_back"
    />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="?android:attr/actionBarSize"
    android:background="@color/white"
    android:gravity="left"
    >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/tv_newsdet_name"
        android:textSize="18sp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="5dp"
        android:textStyle="bold"
        android:textColor="@color/cyan"
        android:background="@color/grey"
        android:paddingLeft="1dp"
        android:paddingRight="1dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/tv_newsdet_time"
        android:textColor="@color/white"
        android:textSize="18sp"
        android:layout_toRightOf="@+id/tv_newsdet_name"
        android:paddingLeft="1dp"
        android:paddingRight="1dp"
        android:background="@color/grey"
        android:layout_marginTop="5dp" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Text"
    android:id="@+id/tv_newsdet_text"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="1dp"
    android:layout_below="@+id/tv_newsdet_name"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />
</RelativeLayout>

My onClickListener with AndroidAnnotations

 @ViewById
 ImageButton btn_newsdet_back;


    @Click(R.id.btn_newsdet_back)
    void back() {
       Log.i(TAG,"back");
       mActivity.popFragments();
    }

EDIT onClick is working (called), when its below the TextView. Can anybody explain why?

enter image description here

Bobbelinio

I solved it. The problem was I was using a transparent Actionbar which was the overlay I was looking for.

The following line in my onCreate() solved this:

getActivity().getActionBar().hide();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

NullPointerException using Imagebutton in fragment

From Dev

ActionBar tab: onclick button from fragment 1 to fragment 2

From Dev

requestedFeature() must be called before adding content - implementing Spinner in ActionBar in Fragment

From Dev

SignInButton in Fragment - and onClick is never called in MainActivity

From Dev

Onclick() in a Parent Fragment does not get called

From Dev

Button onClick method never called inside Fragment

From Dev

Using ActionBar Inside Fragment class in android

From Dev

Imitate ActionBar menu with ImageButton

From Dev

ImageButton in ActionBar for GoBack in WebView

From Dev

Actionbar will not align correctly (RelativeLayout)

From Dev

WinRT - ImageButton for transparent PNGs

From Dev

RelativeLayout Background Transparent

From Dev

Transparent Overlay ActionBar with AppCompat?

From Dev

Transparent ActionBar is not working

From Dev

how to make the actionbar transparent

From Dev

Transparent Overlay ActionBar with AppCompat?

From Dev

Refresh animation in actionbar customview imagebutton

From Dev

Android Imagebutton fragment

From Dev

Inflate imagebutton on fragment

From Java

How to have a transparent ImageButton: Android

From Dev

Transparent background in ImageButton with ripple effect?

From Java

Dynamic ActionBar title from a Fragment using AndroidX Navigation

From Dev

How to do Up navigation using ActionBar's tabs and Fragment?

From Dev

My Fragment got overlapped by ActionBar Tabs when using SystemBarTint

From Dev

My Fragment got overlapped by ActionBar Tabs when using SystemBarTint

From Dev

Filter listitem in tab fragment using the edittext present in the actionbar

From Dev

RelativeLayout - Keep Fragment at the bottom

From Dev

ImageButton onClick change color

From Dev

OnResume() not called in Fragment using tabLayout and ViewPager

Related Related

  1. 1

    NullPointerException using Imagebutton in fragment

  2. 2

    ActionBar tab: onclick button from fragment 1 to fragment 2

  3. 3

    requestedFeature() must be called before adding content - implementing Spinner in ActionBar in Fragment

  4. 4

    SignInButton in Fragment - and onClick is never called in MainActivity

  5. 5

    Onclick() in a Parent Fragment does not get called

  6. 6

    Button onClick method never called inside Fragment

  7. 7

    Using ActionBar Inside Fragment class in android

  8. 8

    Imitate ActionBar menu with ImageButton

  9. 9

    ImageButton in ActionBar for GoBack in WebView

  10. 10

    Actionbar will not align correctly (RelativeLayout)

  11. 11

    WinRT - ImageButton for transparent PNGs

  12. 12

    RelativeLayout Background Transparent

  13. 13

    Transparent Overlay ActionBar with AppCompat?

  14. 14

    Transparent ActionBar is not working

  15. 15

    how to make the actionbar transparent

  16. 16

    Transparent Overlay ActionBar with AppCompat?

  17. 17

    Refresh animation in actionbar customview imagebutton

  18. 18

    Android Imagebutton fragment

  19. 19

    Inflate imagebutton on fragment

  20. 20

    How to have a transparent ImageButton: Android

  21. 21

    Transparent background in ImageButton with ripple effect?

  22. 22

    Dynamic ActionBar title from a Fragment using AndroidX Navigation

  23. 23

    How to do Up navigation using ActionBar's tabs and Fragment?

  24. 24

    My Fragment got overlapped by ActionBar Tabs when using SystemBarTint

  25. 25

    My Fragment got overlapped by ActionBar Tabs when using SystemBarTint

  26. 26

    Filter listitem in tab fragment using the edittext present in the actionbar

  27. 27

    RelativeLayout - Keep Fragment at the bottom

  28. 28

    ImageButton onClick change color

  29. 29

    OnResume() not called in Fragment using tabLayout and ViewPager

HotTag

Archive