I am making a SeekBar in my Android Java application for the first time, but the slider circle is not in the middle of the line as I would expect, but a little above it. I can't figure out why this is the case.
There is an image of the slider at http://i.stack.imgur.com/AAGkM.jpg
My layout for the slider is:
<SeekBar
android:layout_width="match_parent"
android:id="#+id/seekBar"
android:layout_height="0dp"
android:layout_weight="0.5"
android:background="#ffff4007"
android:progress="0"
android:max="100"/>
You can post the code of your layout to better help you, maybe you can try this
android:gravity="center"
To do this use
android: progress=0
In java use
Seekbar.setmax(to set maxm value..as integer);
Related
I don't want to change the font size of Android Studio itself, but rather the font size of the app i'm working on. All the search results I have found talk about the user interface or zooming in.
I'm Working on a tic-tac-toe beginner project and the button text always is so small. Any tips on how to increase it?
Here is its part in the xml file:
<Button
android:id="#+id/button_0"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
Many thanks in advance for anyone who helps
Add android:textSize property into Button, eg:
<Button
android:id="#+id/button_0"
android:layout_width="0dp"
android:textSize="20sp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
https://developer.android.com/reference/android/widget/TextView#attr_android:textSize
One way is to change the textSize attribute in the XML file. The other way is to mention it in the program.
Button btn = findViewById(R.id.button_0);
btn.setTextSize(20.0f);
where btn is the name of the button.
Note: The size mentioned in the setTextSize() method must be a float value.
I'm building a simple calculator app and i cannot get ride of extra grey lines next to an ImageButton
Button Code
<Button
android:id="#+id/button_clear"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/white"
android:text="AC"
android:textColor="#color/indigo"
android:textSize="18sp" />
ImageButton Code
<ImageButton
android:id="#+id/button_back"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/backspace"
android:background="#color/white"/>
As you can see, the buttons are perfect but the ImageButton have grey lines next to them.
I tried settings the Parent background to 'White' and setting the ImageButton background to '#null' too
I tried an Imageview and the Problem still exists
i tried setting the image as background to the button and it still exists
i even tried setting negative margin towards left and right and the problem still exists
Can someone help me out please?
Add this in your ImageButtons
style="?android:attr/borderlessButtonStyle"
I have a suggestion: Use a button to display the ⌫ symbol. For information on how to get the desired results visit: How to make ⌫ symbol backward-compatible in Android Studio?
I have a viewpager that recreate parallax effect using ViewPager.PageTransformer()
I have a clip art made of several pieces (clouds, tree etc...) that i have to place very precisely on a layout of one of my fragment, so can animate them later independently , but i'm unable to place any item precisely. On a relative layout, it seems that each time i move one items with the mouse, it goes either right , left, or top etc.., i want to be able to place them pixels by pixels, a bit like a puzzle
Is there any any layout (mspaint style) i could use that would let me place freely my item using my mouse for example, without having to obey any rules of placement ?
Thanks a lot
I have been able to use RelativeLayout in Android Studio to place items precisely. The images to tend to "snap" along grid lines when close, but I think that with careful mouse movement you can make it work. This will be very dependent upon the screen size and will not scale up/down well since it is using margins, but it may be what you need.
Here is the layout I tested with in Android Stdio 2.1. I hope this helps.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView1"
android:layout_width="219dp"
android:layout_height="219dp"
android:background="#00FF00"
android:layout_marginRight="26dp"
android:layout_marginEnd="26dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="58dp" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="219dp"
android:layout_height="219dp"
android:background="#FF0000"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="53dp"
android:layout_marginStart="53dp" />
</RelativeLayout>
OK, Im starting to get the hang of how XML operates with the Android interface, but I've ran into a problem...
I just have a HorizontalScrollView with a RelativeLayout inside to which I will place other views later. The HorizontalScrollView as you can see is sitting above a button, and below another button. I like where its placed, but I dont want it exactly right above and below the buttons. I would like some spacing (padding). Ive tried adding padding but it seems to have no effect...
Heres my attempted XML:
<HorizontalScrollView
android:id="#+id/scrollview_xyzInfo"
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_above="#+id/button_refresh"
android:layout_alignParentRight="true"
android:layout_below="#+id/button_mySettings"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:background="#drawable/refresh_selector" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
</RelativeLayout>
</HorizontalScrollView>
Any help would be much appreciated :-)
Nevermind! Use margins when seperating two views like so:
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
Answer Found at:
Padding not working Android
Padding and margin works only with LinearLayout. Which layout are you using?
Suppose I have made a diagram e.g a circle on android mapView. Now I want to remove/blackout/hide all other maps except that portion. I can zoom in out that portion too
Is this possible?
Best Regards
I have a similar problem of make map view inside certain area.not sure it will help you or not but you can try it.
What you should do is take image of circle(Background is Transparent) and put your image as background in Linear layout. and inside that LinearLayout you can put map view.
your xml will Look like below.
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/Circle_back" >
<com.google.android.maps.MapView
android:id="#+id/whereami_mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="YOUR API KEY"
android:clickable="true" />
</LinearLayout>
</LinearLayout>
i have to view it inside rectangle box. below is the similar screen shot you will get while running. you d'nt need to hide rest of the part of Map.
hope it will help some how what are you looking for.
Make a trick
Zoom will work in your case. Set zoom level and
Use android:clickable="false" in your layout file.
;)