Visibility trouble with framelayout children - android

I have a problem with the children of my FrameLayout when I change their visibility dynamically :
The FrameLayout is composed with a simple ScrollView that is allways visible and a RelativeLayout that represents a search bar and that is gone by default but that can be set to visible dynamically if the user press a button on the action bar.
So when the user press the action bar button and the search bar is GONE, there is no problem, the search bar appears like it has to. But when the search bar is VISIBLE impossible to make her disappear. I don't know why because the state of the bar is well set to GONE when I display it in the log but it's like the FrameLayout was not refreshed.
Someone knows that probleme or has a solution to mine ?
There is the code:
....
<FrameLayout
android:id="#+id/frame_layout_movie_detail"
android:layout_below="#+id/movie_actionbar">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
....
<ImageView
android:id="#+id/iv_movie_detail_poster"
android:scaleType="fitCenter"
android:src="#android:drawable/ic_menu_report_image" />
....
</RelativeLayout>
</ScrollView>
<include
android:id="#+id/include_search_bar_movie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
layout="#layout/search_bar" />
</FrameLayout>
....
search_bar.xml:
<RelativeLayout
<EditText />
<ImageButton />
</RelativeLayout>
the code to display and hide the search bar:
private void onDisplaySearchBar() {
if (search_bar.getVisibility() == View.GONE)
search_bar.setVisibility(View.VISIBLE);
else
search_bar.setVisibility(View.GONE);
search_bar.invalidate();
}
thanks

Related

Android bottom toolbar disappears when fragment fills screen

I'm working on an android app and am using a toolbar at the top of the screen and a navigation bar at the bottom of the screen. I'm using a single activity to create the top and bottom toolbars and fragments to change the content between the toolbars. However, when the contents in the fragment go beyond the size of the screen, the bottom bar disappears.
Here is my home activity xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_home"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.rentables.testcenter.HomeActivity">
<include
android:id="#+id/toolbar_main"
layout="#layout/toolbar_main"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<fragment android:name="com.rentables.testcenter.HomeFragment"
android:id="#+id/fragment_place"
android:layout_weight="0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="#layout/fragment_home" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="bottom">
<include
android:id="#+id/toolbar_navigate"
layout="#layout/toolbar_navigate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|bottom"/>
</LinearLayout>
</LinearLayout>
Im guessing it's because of the inner linear layout I have, but I wasn't sure how else to get the nav bar to stay static at the bottom. Any help would be awesome. Thanks
Figured it out. I just changed the whole thing to a relative layout, got rid of the inner linear layout, and instead of gravity I used alignParentBottom="true".

Custom action bar leaves black space on the left android?

I have created a custom action bar
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Choose"
android:textColor="#000000"
android:id="#+id/mytext"
android:textSize="18sp" />
</LinearLayout>
The java code
android.support.v7.app.ActionBar bar = getSupportActionBar();
bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
bar.setCustomView(R.layout.action_layout);
The screenshot
As you can see it leaves a mall black space to the top left of the screen. I don't want it. I want it to be pure white.
What needs to be done to achieve this.
Try to call setDisplayShowHomeEnabled() with false.
http://developer.android.com/reference/android/app/ActionBar.html#setDisplayShowHomeEnabled%28boolean%29

how to make Arc menu with scroll?

I need a arc menu like above image but it is not scrolling. I need that i can add more menus and it should come from bottom while scrolling.And these menu will come after a tap on center button. Please help me.
I have a SemiCircularRadialMenu and there are individual fragments for every menu. I am opening fragments on clicking different menu but when I click on fragment, it also covers that SemiCircularRadialMenu. I want that when I click on the fragment, there should be no effect on SemiCircularRadialMenu.
My XML Code is given below (XML)
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<com.touchmenotapps.widget.radialmenu.semicircularmenu.SemiCircularRadialMenu
android:id="#+id/radial_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:padding="5dp" />
Code link for Semi Circular menu http://hasmukhbhadani.blogspot.in/2014/04/radial-menu-semi-circular-radial-menu.html (CIRCULAR OUTPUT SCREEN: is Semi Circular menu )

How to remove Click location after TranslateAnimation?

I have full screen RelativeLayout that contains the following:
1. FrameLayout, full screen, displaying content.
2. LinearLayout, act as a control menu, stay on top of the content #1, must be able to slide or fade in/out on request(I actually have two of these. One at the top of the screen, another at the bottom).
I have the view display correctly, the menu controller slide/fade in and out when menu button pressed. But when I slide and fade the view out, the click action remain. How do I remove this action?
I tried to call menuLayout.setVisibility(View.GONE); but the action remains.
I read some issue with TranslateAnimation but I cannot get it to work.
Can someone tell me how do I fix this? Example would be appreciated.
XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99000000"
android:layout_alignParentLeft="true"
android:gravity="center_vertical"
android:id="#+id/contentFrame"
>
<ViewSwitcher
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/viewSwitch">
<include layout="#layout/main_car" />
</ViewSwitcher>
</FrameLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="43dp"
android:background="#drawable/um_top_bar"
android:layout_alignParentTop="true"
android:id="#+id/topMenu"
android:gravity="top"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/um_btn_home"
android:id="#+id/homeMainBtn" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/exp_menu_btn"
android:id="#+id/menuMainBtn" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF000000"
android:layout_alignParentBottom="true"
android:id="#+id/bottomMenu"
android:gravity="top"
>
<include layout="#layout/menu_bottom" />
</LinearLayout>
Ok, I got it to work at last. For anyone who may face the same problem, here's what I did.
I place empty layer and separate all menu content into separate XML file.
Here's the code:
/** Resetting bottom menu content */
private void resetBottomMenu(boolean isOpen){
bottomMenu.removeAllViews();
bottomMenu.addView(loadBottomMenu(isOpen));
// Control event handler goes here.
}
/** Load bottom menu content from XML */
private LinearLayout loadBottomMenu(boolean isOpen){
LinearLayout result = null;
if(isOpen){
result = (LinearLayout)View.inflate(this.getApplicationContext(), R.layout.menu_bottom_open, null);
}else{
result = (LinearLayout)View.inflate(this.getApplicationContext(), R.layout.menu_bottom, null);
}
return result;
}
Every time I want to slide menu in, I called resetBottomMenu then start animation on bottomMenu. If I want to close the menu, I start animation then resetBottomMenu.
It's important to remove child view in that Layout since that will remove the click action.
P.S. I'm not sure if this is the best way of doing it but I can confirm that it works. I have three menu that need to be fade/slide and they work perfectly now :)

Unable to hide TitleBar, becomes transparent

I want to delete the title bar from my app, but when use the following code, the title bar isn't hidden, in fact it becomes transparent and the content is pushed downwards:
#Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
So, I have a gap where the title bar used to be (between the notification bar and the app).
I have searched everywhere but haven't found something similar.
Edit:
I have tried both of the solutions given by seretum and harism (shown below) but I'm still unable to find the problem, this is a part of my xml code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff">
<ImageView android:id="#+id/title"
android:src="#drawable/main"
android:layout_width="480dp"
android:layout_height="155dp"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"/>
Somehow, the ImageView isn't aligned to the Top of the relative layout...
Last Edit. SOLUTION:
So, I tinkered with the xml and found out that when you set a custom dimension to a widget and so use the Realtuve Layout; no matter if the Title bar is present or not, the Widget will always be under it. So, here is the solution (you need to put the object in a layout):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff">
<LinearLayout android:id="#+id/title"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:maxHeight="155dp"
android:maxWidth="480dp"
android:layout_height="wrap_content">
<ImageView android:src="#drawable/main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"/>
Have you tried requesting no title in different order;
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
Works for me.
In your app's AndroidManifest.xml, inside the "application" tag, put
android:theme="#android:style/Theme.NoTitleBar"
That will remove your bar from every activity.

Categories

Resources