i want to warp views in android ,
for example need to create wave on top of screen and any time can convert it to straight line
or
use a button in bottom navigation bar which create a wave on bottom navigation
please visit screenshots:
This is new Design as per material IO. It is introduced in material design 2. You need to add anchor for using that type of view.
There are some changes which need to be noted.
This is AppBar which is placed at bottom not BottomNavigatioView.
It can be used for multi-purpose, so chose your use wisely.
You can modify design as your need.
Following code can be used to achieve that functionality.
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Other components and views -->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:navigationIcon="#drawable/ic_menu_24"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="#id/bar"/>
</android.support.design.widget.CoordinatorLayout>
The FloatingActionButton can be anchored to the BottomAppBar by setting app:layout_anchor or by calling CoordinatorLayout.LayoutParams#setAnchorId(int).
Note: This things are introduced in Android P versions, you need to
have Android studio 3.2 or above.
Checkout this link for detailed explanation :
Implementing BottomAppBar: Material Components for Android
Related
I have been trying for a long time to make Cards similar to appearance that of Google Play Store, ie cards of Different sizes , with images and all inside the card. Any tips on how to proceed.
Basically you just create a layout (RelativeLayout, LinearLayout, etc) as a child of your cardview element and make it look however you want.
For example...
<android.support.v7.widget.CardView
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="200dp"
card_view:cardElevation="2dp"
card_view:cardBackgroundColor="#android:color/white"
card_view:cardCornerRadius="2dp">
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent">
//Your desired layout here
</RelativeLayout>
</android.support.v7.widget.CardView>
You can take a look at the MaterialList implementations for some good examples.
I am making an app, and I have the following XML file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#f4f4f4" >
<ExpandableListView
android:id="#+id/lvExp"
android:layout_width="match_parent"
android:layout_height="325dp" />
<Button
android:id="#+id/add_claim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Claim" />
</LinearLayout>
I made a button called View_list that wants to see only the expandable list view on the entire page. what I did is create a new XML file, and added the follwing include statement:
<include android:id="#+id/lvExp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
However, I realized that this will now work for two reasons
1 - There is no layout ID
2- I only want the list, not the button and everything else I am going to put in the original layout. What is going to happen is if I add something to the list, I need to be able to view it without the option of adding antthing to it.
My question is therefore this:
How do I find the layout ID and how can I prevent the entire layout from showing, and only show the list. I would really appreciate some advice.
The include should say:
<include layout="#layout/View_list"
android:id="#+id/lvExp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
This includes the View_list.xml layout in another layout.
But I dont really understand why you would use an include here if you don't want to re-use the whole layout, but only the list part of it. includes exist to easily use layouts in other layouts, if you need just a ListView, use just a ListView.
EDIT: I'm not sure anymore if I got your question right, but I'll not delete the answer because you commented on it.
If you want to hide the button or other Views on the click of a button, you can set their visibility to gone programmatically.
I'm making an app for Android with Java in eclipse, and it will have multiple screens. One screen will contain a canvas with 2D graphics, and some buttons below the canvas. But I'm a newbie at Android so it's still a little messy to me. Seems like a new Paint() in a class which extends View always is fullscreen (?) so I tried to solve it with Fragments where I put the canvas/newPaint() in one Fragment and the buttons in another one. But my app crashes when I try to add the Fragments in the xml file, and I don't know why.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="#+id/game_fragment"
android:name="com.example.tictactoe.GameFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="#FF0000"
tools:layout="#layout/game_view" />
<fragment
android:id="#+id/game_fragment2"
android:name="com.example.tictactoe.GameFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FFFF00"
tools:layout="#layout/game_view" />
Is there any other way of getting a 2D graphics canvas together with some buttons on a screen,
or can someone help me out with the fragment solution?
Thanks in advance!
Your stacktrace gives what the error is - GameFragment is not a class inheriting from Fragment. You need to ensure that you are placing Fragment classes appropriately in your layout.
Also from looking at your layout, you are placing GameFragment layout twice in the same root view. This looks wrong on some level. I mean if you have your buttons in a different layout, shouldn't you be using that layout? Also, as a tip, inflate the layout for the fragment by overriding the GamrFragment's onCreateView() method (you should see this method once you have inherited from the Fragment class appropriately).
And last but not the least, when using Fragments, ensure that you use the right version uniformly (if you use the fragments from the support package, stick to using it uniformly).
I am creating an Android Application having two layouts. All layouts have some common features like the top part is same and the only difference is at the bottom part.
Currently I have created two separate java files for two layouts. And I have simply copied the code which implements similar functionality like buttons etc
The part seen is the pic is the top part of the layout which is same in both the layouts;
Is there any way with which I can optimize the functionality by having reusable code
In my opinion this is helpful using <include> in your main layout.
STEP:
you have to create one XML file for your common layout.
topbar.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width=”match_parent”
android:layout_height="wrap_content"
android:background="#color/titlebar_bg">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/gafricalogo" />
</FrameLayout>
like this way now you have to include this XML file to where you have to require.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal">
<include layout="#layout/topbar"/>
...
</LinearLayout>
I think this tab bar can also be used for this..
below is the link for complete tutorial...
http://mindstick.com/Articles/7e659092-3046-4461-97ba-b2b28616241e/?tab%20layout%20android%20application
I am adding accessebility support to some application. It works fine with standart UI elements (buttons for example), but for some reason does not work with my custom element, wich is RelativeLayout with ImageView and TextView (it looks like icon). I've defined android:focusable="true" and set contentDescription.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
...
android:contentDescription=”my content description”
android:focusable="true">
<ImageView
...
/>
<TextView
...
/>
</RelativeLayout>
Could someone please list here all posible causes?
UPDATE:
Is there some way to know what layouts are on the screen at the moment and what order do they have (some layouts are transparent)?
Use hierarchy viewer for understanding where is your invisible views.
The android docs have a section about designing for accessibility, is this any use to you?