I am a just a beginner to Android Studio and have started as a hobby, and to learn it's basics I have tried to make a simple calculator in Android Studio(Kotlin).
The problem is that if the answer is to long to be diplayed in the text view box it cuts out...So to solve this problem I made the text view Horizontally Scrollable using "Horizontal Scroll View" in the xml File,
But now the problem is when the user types the text after the view is full, it does not automatically scroll to the last digit he has typed, rather he/she has to manually scroll it to the end. Here is the code for the text box which displays the result:
<HorizontalScrollView
android:id="#+id/horizontalScrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<TextView
android:id="#+id/tvExpression"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#1C1C1C"
android:textColor="#FFFFFF"
android:textSize="27dp"
</HorizontalScrollView>`
Could you please tell a way so that each time a new value is added to the box, it automatically scrolls to the right most part of the box, so that the users can see his/her last inputted value?
Please Help me!
Thanks,
Shaurya
Preferably delete a tag of HorizontalScrollView Because this makes textview More flexible to contain the result of the calculator.
You can also select the max line of the textView by using this attribute:
android:maxLines="select int number"
If you want a way to make the scroll of horizontalScrollView from the end
you can use this code in your activity that contents the horizontalScrollView:
horizontalScrollView.postDelayed(
Runnable {
horizontalScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT) },
100L
)
Related
Text View2 is visible while Text View1 isn't visible. How to resolve this problem?
There aren't enough information in the picture you posted But I guess TextView1 might cover TextView2 . In that case you may change the positions or add a function which change one's visibility to "invisible" while another is visible.
#Atul Awasthi, replace android:layout_height="200dp" for the RelativeLayout with
android:layout_height="wrap_content"
android:minHeight="200dp" and that will fix your problem.
So I just downloaded Android Studio onto this compute. When the Layout Editor interface loads and I try to drag the XML items onto the screen, they do show up in the constraintView but not in the editor.
I get a render error that states "Couldn't resolve resource #string/helegrtsrewfrtsaw"
<TextView
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginLeft="132dp"
android:layout_marginStart="132dp"
android:text="#string/helegrtsrewfrtsaw"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
Because you are using ConstraintLayout as parent layout, you need to to remove android:layout_width and android_layout:height then define constraints of your Switch in the Attributes tab on the right hand side.
It will allow system to arrange your View width/height and position base on parent layout (instead of using specific predefined values).
P.s: If you click on the exclamation mark !, it will tell you to add the constraints or the View will jump to position (0,0).
I just started learning how to develop apps for android. I have a seamingly easy question but I couldn't find an answer to it.
I'm trying to do the opposite of what wrap-content does (in the context of an image button).
I want my content to adjust to the frame of the button, whereas wrap-content matches the frame to the content.
Is there a way to do that? It sounds easy enough but I couldn't figure out how. Thanks in advance!
EDIT : I think I've expressed myself poorly, sorry.
What I really want is to be able to resize the frame of my image button, with its content adjusting by itself to the frame, instead of having the button crop around a static picture.
Use match_parent
From Android documentation:
Match Parent: Sets the dimension to match that of the parent element. Added in API Level 8 to deprecate fill_parent.
Example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
Can somebody please help me out in designing vertical tabs like in the given pic(taken from hello sms app)
I'm not asking for a code snippet , so please don't ditch this question as a homework type. What I would want to know is the approach that I should take. Do I have extend the stock TabLayout or an existing tablayout with a few styles and UI customizations? Your pointers to the right resource would be of great help. Thanks
you can achieve this using multipane layout in android. on your right side create the listview fragment and right side implement details screen using fragment. if you wants to slide the left side listview use slidepanelayout.
<android.support.v4.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/slide"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<fragment android:id="#+id/leftpane"
android:name="com.example.package.left"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="left" />
<fragment android:id="#+id/rightpane"
android:name="com.example.package.right"
android:layout_width="350dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_weight="1"
/>
</android.support.v4.widget.SlidingPaneLayout>
I think this will not be achieved by TabLayout as it only supports Horizontal Orientation.
But you can go with SlidingPanel with NavigationDrawer where you can design DrawerItemLayout as per your requirement and get the exact layout you want.
Please check links #1. & #2.
I think this can reduce your efforts and you can get your task done easily.
No, you dont have to custom any view. You can just
Use RecyclerView for avatars list. If an avatar is selected, just changed background of the selected item to black U shape as in your design.
Use a detail view to display your avatar information.
You cannot use TabLayout here as it would not be appropriate for your purposes. What you could do is to have two layouts - maybe linear (or relative) to basically split the screen into the top part with a layout_weight of maybe 2 and the bottom layout with a layout_weight of 8 (for a 20/80) split.
From here, it's just a matter of designing your layouts. It looks like your top layout holds something like a spinner widget. You could either use this or a list view object. Your bottom layout definitely holds something like a list view. You could implement your own list view widget with some kind of a design in each row or you could have an xml layout file and reference this in your ArrayAdapter. Really, your choices are endless. For the left part of your bottom layout, you could probably use a vertical LinearLayout to hold the images of the people in the conversation.
And also don't forget to hide the ActionBar - if you want that.
what I would do is to split screen in a given ratio into two parts. Insert a list view with an adapter into left hand side and use fragments for the right hand side. But using tables is not a good idea. Using Fragments will make the things way easier. Check this link for an overview. Look at 2.2 and 2.3 sections.
And for the right hand side, inside fragment, you can use another list view with images and text.
You can achieve this by using a NavigationDrawer and a listview inside this navigation drawer.
this listview will be using a seperate xml layout for its row. which will have that image views inside as shown in the screenshot.
This is not a listview, its just a sliding menu. Learn about the sliding menu and you can achieve the design that you want. This will help u. https://github.com/jfeinstein10/SlidingMenu
I'm programming on ADK and I got one screen with a text at a huge font so the whole text can't appear on the screen. I want to know to do slide the finger up and see the text below, sliding it as we do with normal texts on Android.
Put your TextView inside ScrollView in XML like:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/txt2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="txt2"/>
</ScrollView>
OR If You don't need to use a ScrollView actually.
Just set the
android:maxLines = "AN_INTEGER"
android:scrollbars = "vertical"
properties of your TextView in your layout's xml file.
Then use:
yourTextView.setMovementMethod(new ScrollingMovementMethod())
in your code.
It scrolls automatically without any issues.
Create a custom listview! Like so : http://www.vogella.com/articles/AndroidListView/article.html#androidlists_overview