How to define custom margins to StepperLayout navigation buttons - java

I have a StepperLayout that displays a list of questions to the users. However, half of the "NEXT" navigation button is hidden after giving it a background color. I want to define custom margins and alignments to the navigation buttons. See the gif image below.
I have tried overriding the codes used for the NEXT and BACK button but that displays duplicate buttons. I have also tried adding some paddings to the StepperLayout but still, it didn't help.
<com.stepstone.stepper.StepperLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/stepper"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:ms_activeStepColor="#color/stepper_btn_blue"
app:ms_nextButtonBackground="#color/stepper_btn_blue"
app:ms_backButtonColor="#000000"
app:ms_completeButtonColor="#color/colorWhite"
app:ms_completeButtonText="Finish"
app:ms_stepperType="tabs"
tools:theme="#style/AppTheme" />

Related

android:How to move a RelativeLayout permanently after animation

This is the activity.xml and content_my.xml is a RelativeLayout and menu.xml is LinearLayout. Content layout(RelativeLayout)in the top and menu layout(LinearLayout) under the I want to move the Relative layout(content layout) left of screen and access the menu layout under it. content layout is in the top of menu layout after animation it menu cannot be accessed. In contentlayout I have add ListView. Please help me how to move the RelativeLayout left permanently after animation.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.bwd.demo.mybrand.My">
<include layout="#layout/menu" />
<include layout="#layout/content_my" />
</android.support.design.widget.CoordinatorLayout>
In your content_my.xml you have to assign an ID to your RelativeLayout :
android:id="#+id/rl_content"
Then you cast the xml in Java code in your Activity so you can use it :
RelativeLayout rl_content = (RelativeLayout) findViewById(R.id.rl_content);
Now there are multiple options to animate it.
Since you want to access something below the layout, I would recommend
using ViewPropertyAnimator, then you can do it with one line.
A minimal implementation would look like this :
rl_content.animate().translationX(0); // -> animates **TO** 0 on the X axis
would move the left border of the layout to the left side of the screen. If you want it further then you need a negative value.
or you can use the translationXBy() method f.e. :
rl_content.animate().translationXBy(-50); // -> animates **BY** -50 on the X axis
//(negative values are to the left)
Also interesting :
TranslateAnimation -> not recommended in your case, because it does not really move the layout, only makes it look like its moving, so you would have trouble accessing the menu under the RelativeLayout.
ObjectAnimator

Tips horizontal scroll with textbox

I would like to make horizontal swipe scroll with images and text views on it, 3-4 views.
Like tips screen on applications.
But, don't know which component to use, I need something like tabs(3-4 different layouts) but I dont want to show tab menu up. Just full screen, few buttons down, and in middle textbox with tip(which i want to animate later), everything is same in every layout just different image and text.
No code here in question because i stuck on beginning and need few tips what to use or some linked tutorial.
Here is how you can do this.
<ViewFlipper
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/pro_flip"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
//put your child elements for first page on this layout
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
//put your child elements for second page on this layout
</LinearLayout>>
</ViewFlipper>
Content on the first layout will be visible to the user at first, when he swipes the next layout will be loaded.
ViewFlipper should be sufficient for simple content like you mentioned. If you want something more look into ViewPager.

Android – How can I Move a Layout Partially Offscreen?

I am trying to make a sliding menu in an android application I am building for my school, and whenever I open the menu, the menu button, in addition to the other views I've tried, are scaled to fit in the remaining 25% of the layout still on the screen. So my question is, how can I disable this scaling so views can be moved offscreen along with their parent layout?
This is the XML file of the layout I am trying to move. It contains the misbehaving button:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/background_color"/>
<ImageButton
android:id="#+id/menu_button"
android:layout_width="56dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:background="#drawable/menu_button"/>
</RelativeLayout>
This is what the menu looks like closed:
This is how it looks when opened:
And this is how I want it to be when opened. Notice the menu button has moved offscreen.
Any help is appreciated.
EDIT:
Although it may work for a single button, I do not want to make the views invisible, I would like to move them off the screen to the right. If, for example, I wanted to add a TextView that fills a horizontal row on the layout, the TextView would be scaled to 25% of the screen upon opening the menu. Instead, I want it to retain the size and shape of all views and make them move partially off screen.
When menu opens up, set the visibility of menu icon to GONE
icon.setVisibilty(View.GONE);
and when close , again set visibility of icon to VISIBLE.
icon.setVisibilty(View.VISIBLE);

Java Android/Eclipse: how to get a screen with a canvas and some buttons?

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).

Scrolling in a view containing a ListView (Android)

In one of my activities I am showing certain information and at the end I have a ListView.
So my layout looks a bit like:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="30dip"
>
...
<ListView android:id="#android:id/android:list" android:layout_width="wrap_content"
android:layout_height="fill_parent" />
</LinearLayout>
When I run the application in the emulator I see that the information before the list view is always shown in the screen and there is a vertical scroll for the ListView only.
Is there a way to change this scrolling behaviour ?. What I would like to have is a vertical scroll for all the information in the screen, not only at the level of the ListView.
I tried wrapping the LinearLayout with a ScrollView, with different combinations of the android:layout_height attribute for all the views involved but I did not get the effect that I was looking for. Besides, some people say that it is a pretty bad idea to wrap a ListView with a ScrollView :
Android ScrollView layout problem
Scrolling with Multiple ListViews for Android
Thanks for any other ideas.
I've not tried this, but you might want to look at you tube video:
Google I/O 2010 - The world of ListView
http://www.youtube.com/watch?v=wDBM6wVEO70
Starting at time 27:11, it talks about how to make info above and/or below a ListView scroll with the ListView. It refers to scrolling headers and footers, but it does say you can put anything you want in them.

Categories

Resources