What should I do in this case? [closed] - android

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have antwo fragments like this:
What I want is when I press the "MapView" button, the whole screen will be like this:
so what should I do in this case to have the best UX? should I turn two fragments off and add a new one? Pleases give me some ideas! Thank you!

It's better to convert the whole stuff into 4 fragments.
Fragment 1: Search Bar
Fragment 2: Two Buttons
Fragment 3: Bottom list
Fragment 4: The map
So in this case you can listen to click on each button and replace the corresponding container having fragment 3 with fragment 4. If your design requires to hide fragment 1, it could also be done in this case.

I recommend to use a PagerTitleStrip layout. Just replace the content below the title strip by a fragment transaction. Feel free to ask, if you need further information (how to set it up).
A good starting point are the docs, the guidelines and maybe this tutorial.
Btw: one of my apps does a similar job, have a look: Libre Drive

You need to have a parent layout which will have two buttons at top. MapView and List View. Then Display desired Fragment with click on button through java code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="MapView" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="ListView" />
<fragment
android:name="com.example.app.myFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout="#layout/my_fragment"
/>
</LinearLayout>

Related

Android: Any Ideas on how to make a Hearthstone/Magicka type of card? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Details:
I was wondering how to create an object in android that has multiple layers of graphical elements. A good example would be a Magicka or Hearthstone card. They have 3 elements: the background of the card, the image of the creature, text describing something + stats.
The idea behind this is to have fewer images that can be put together to create a great amount of cards. I should mention that in my case the background card and the creature are vectors (SVG).
How do you put all of these elements together in one card-thing that can later be displayed&animated?
You can use proper layout.
Most reasonable to me is using RelativeLayout.
You can put all views:
background (can be a separate view or background view param)
image (ImageView)
text (TextView)
For example:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="160dp"
android:layout_height="240dp"
android:background="#color/aaa">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:src="#drawable/cat_filmy_main" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:text="Movie Killer" />
</RelativeLayout>
And the effect is:
Also, consider creating your own view. How to do that can be found here:
https://code.tutsplus.com/tutorials/android-sdk-creating-custom-views--mobile-14548

Android EditText just like Google's Allo messaging app [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to design edit-text just like Allo messaging app in which on scrolling down the list of messages, message-view is still visible behind that edit text view as shown in image.
How to design this type of edit text view?
Aligning the EditText at the bottom in front of the list should be pretty easy. I would recommend the following layout:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ScrollView>
<EditText
android:layout_alignParentBottom="true"
android:layout_margin="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
You will still have to add elements to your ScrollView or replace it with a ListView, but this should do the trick.
As a side note, elements in the layout file that are added last will be 'in front' of the other views. Because the last element in our layout is the EditText, it will always hover on top of the ScrollView.
Hope this helps!

Android: How to implement quiz app [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm trying to implement an Android app which includes a part where user can do a quiz. Since I'm kinda new to Android app development, I would like some advice on how to implement the quiz part, in terms of layout
I have a set of questions and each has their own respective choice of answers from which I retrieve from my API.
What is the best and easy to implement approach to do this? I need to display each question page by page (Q1 -> Q2 -> ...).
Do I generate a set of Fragments? Or do I somehow use RecyclerView to generate each page for each question?
Any guidance would be greatly appreciated, thanks!
This is kind of a broad question, but here are some quick ideas to get you started.
Off the top of my head, you could have an activity called QuestionActivity (or whatever you want), which would be the main container to display questions. You would then have a QuestionFragment which would be displayed inside the QuestionActivity. Each time you want to display a new question, you would call the Fragment's newInstance() method, passing in the appropriate data in a Bundle each time to populate the layout of the Fragment, then replacing the Fragment in the Activity using a fragment transaction.
As for the Fragment itself, you could maybe do a LinearLayout, with a TextView at the top to display the question, a set of RadioButtons below that, to show some multiple choice options, then a submit Button under that, which the user would use to submit his answer. Then of course you would receive all the click events for these things to determine which answer was selected, etc.
Your QuestionFragment layout might start with something like this...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.david.timedtask.QuizActivity">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/quiz_question"
android:id="#+id/textView"
android:layout_gravity="center_horizontal"
android:paddingBottom="100dp"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option_one"
android:id="#+id/radioButton" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option_two"
android:id="#+id/radioButton2" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option_three"
android:id="#+id/radioButton3" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/option_four"
android:id="#+id/radioButton4" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/submit_button"
android:id="#+id/button"
android:layout_marginTop="50dp"/>
</LinearLayout>
</RelativeLayout>
And this would produce a result looking something like this...
Of course this is all pretty basic, but again, your question was pretty broad. There are plenty of docs available to show you how to actually code all this stuff and put it all together, but hopefully this will get you started.
Good luck!
I don't know what kind of view do you use to show first quiz question but every next question should be shown in same view by changing values of current controls.

how to make one screen working for mutlple tasks in android [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to make an android app which contains four buttons on top of screen and when pressing each button i need different screens below those four buttons.please tell how to make it.
You should Use Fragment...
You can build an activity that contains 1 fragment for buttons, and one view for replace it with a fragment
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
class:"com.example.ButtonFragment"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
tools:layout="#layout/button_fragment" />
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="10"
android:id="#+id/LayoutForReplace"/>
Then you can set action listener of buttons like this:
getActivity().getFragmentManager().beginTransaction().replace(r.id.LayoutForRepalce, new SomeFragment()).commit();

Android Top and Bottom menu [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am new in Android and i don't have much programming knowledge. I want to create top and bottom menus for my android app. i have attached a sample image. Please someone help me
There are two possibilities of how you can achieve something like that:
1) Use a split ActionBar (more information on the ActionBar)
2) You can define it yourself inside an XML-layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/top_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</LinearLayout>
<!-- Your page-content can go here -->
<LinearLayout
android:id="#+id/bottom_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
</LinearLayout>
</RelativeLayout>
Design two custom layout xml one for top menu bar and one for bottom menu bar. And include these xml file in your main xml. Then call the button in custom xml same as calling from main xml in the java file.

Categories

Resources