FAQ Database Discussion Community


I have added 4 radio buttons but I cant find my radio group as i need its id

android,android-layout,radio-group
<RadioButton android:id="@+id/radioButton2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Sachin Tendulkar" /> <RadioButton android:id="@+id/radioButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Rahul Dravid" /> <RadioButton android:id="@+id/radioButton3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Brain Lara" /> <RadioButton android:id="@+id/radioButton4"...

How to delete the complete view on click of delete button in android

android,android-layout,android-activity,android-listview,android-arrayadapter
I have made a custom view that contains an image,text and a delete button. I want to delete the the particular view when I click the delete button associated with it. Please tell how to implement this. Here is my MainActivity.java package com.khurana.nikhil.list1; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.LayoutInflater; import...

Linear layout with textview and button alignment

android,android-layout,android-linearlayout
I am trying hard time to align this paticular layout but unable to set it correctly. can anyone help me out with this. I need exactly the row layout as shown below: This is what I have now: <LinearLayout android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="horizontal" > <TextView android:id="@+id/txtTitle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dip" android:layout_weight="1"...

Can't Open Fragment when clicked button

java,android,xml,android-layout,android-fragments
I have created 2 fragment and their layout, when i click button on profile fragment it should open flat layout, but it force stop application and its not opening the second fragment, i have included fragment code and its layout code.. profilefragment.java public class ProfileFragment extends Fragment { View rootView;...

findViewById returns null when try to find TextView in getView [on hold]

android,android-layout,listview,android-adapter
I don't know but findBtView method cannot fint view and get null all the time. Here are my files: http://pastebin.com/0gJPH8mi

ClassCastException: LinearLayout cannot be cast to (java class)

java,android,android-layout
Having an issue with the following error after trying to add a slideout menu to an activity: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to appname.SlideOutMenu The specific section of code it is finding fault with is this: public class MainActivity extends Activity implements View.OnClickListener { SlideOutMenu root; protected void onCreate(Bundle savedInstanceState)...

How to make EditText work like it does in Twitter Android App for status update

android,android-layout,android-edittext
How does twitter app handle the onclick action on EditText whenever we want to write a tweet? I want to know this because it lets us make a neat user interface and we can manage layout space in a better way. So my question is that when we click on...

Error Parsing XML: not well formed (invalid token)

xml,android-layout,layout
I'm receiving the following message when compiling my android project: Error Parsing XML: Not well-formed (Invalid token) This is the XML layout file where the error is supposed to be: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="0.5"...

Spinner height expands to bottom of screen

android,android-layout,android-fragments
I have a fragment with a spinner in a layout. The spinner xml is: <Spinner android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/spCategory" android:spinnerMode="dialog" android:dropDownWidth="match_parent" android:prompt="@string/label_category_select" /> Populating the spinner is done like this: List<Category> categories = categoryRepository.getAll(); CategoryAdapter adapter = new CategoryAdapter(this.getActivity(), categories);...

Move textview from top to bottom

android,xml,android-layout,layout
In the image above I want to move the textview containing bill microsoft under the image and the other textview. How can I do this? I have written this layout right now. <android.support.v7.widget.CardView android:id="@+id/card_tracks" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="180dp" android:layout_gravity="center" android:layout_margin="16dp" android:elevation="7dp"> <LinearLayout android:id="@+id/main_ll" android:layout_width="match_parent"...

NoClassDefFoundError when using TabLayout

android,android-layout,android-support-library
I wanted to check out the new TabLayout from the Android Design Support Layout. The usage of the TabLayout is just TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout); in Java and <TabLayout android:id="@+id/tabLayout" android:layout_width="match_parent" android:layout_height="wrap_content" /> This is my build.gradle file (simplified a little bit): apply plugin: 'android' android { compileSdkVersion 22...

How to change the layout of DialogFragment when the screen is rotated in Android

android,android-layout,android-fragments,android-dialogfragment,screen-rotation
I have a custom DialogFragment, which contains two DatePicker widgets (from and to, using layout/custom_date_picker). I need change the layout of dialogFragment when the screen is rotated to landscape (using layout-land/custom_date_picker). The configuration of the Activity is : <activity android:name=".activities.MainActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTop"/> The implemented DialogFragment source is: public class DatePickerDialog...

ListView with custom layout for hidden fields?

android,android-layout
Currently I have a listview bound to an adapter (in a DialogFragment): adapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_2, null, new String[] { "_id", "name" }, new int[] { android.R.id.text1, android.R.id.text2 }, 0); listView.setAdapter(adapter); However, I would like to show only the name, but still keep the id, because when the user...

How to get the width of CardView inside RecyclerView

android,android-layout,recyclerview
So here is my RecyclerView's xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/bikename_recycler" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout> And here's the layout inflated by the RecyclerView's Adapter. <?xml version="1.0"...

How to ensure that the views are within screen boundaries

android,android-layout
I have 3 relative layouts (lets call them viewgroups) and layed out like this VIEWGROUP 1 VIEWGROUP 2 VIEWGROUP 3 I want VIEWGROUP 1 and VIEWGROUP 3 to take the space they need to display their contents. Then whatever space left, is allocated to ViewGroup2 (and its contents will be...

Layout xml to Java code

android,android-layout
Does anybody know some tool which convert layout.xml into Java Code generated programmatically. Simple example: <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/redownload_of_assets" android:layout_gravity="center" android:id="@+id/btn_redownload_of_assets" /> Button button = New Button(this) button.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); Reason of that solution is that I need add some...

ViewPager not showing page content / not refreshing after changing the view

android,android-layout,android-fragments,android-viewpager
I am using ViewPager / FragmentPagerAdapter in one of my application fragments to display different listviews in each page (see the picture below) : The problem is that after i change the current view (Fragment) and i reopen it again, the listview isn't rendered (see the picture below) : The...

Nested CardView registration form. How to dynamically size form?

android,android-layout
Here is a picture of my current layout I have been asked to create a form with a big square button at the bottom of the page. At this point I need your help to teach me a lesson about layouts and to help me make this a dynamically sized...

An activity with two listviews in android

android,android-layout,android-activity,layout,android-listview
MainAcitivity public class MainActivity extends Activity { ListView list, listYear; String[] web = { "Google Plus", "Twitter", "Windows", "Bing", "Itunes", "Wordpress", "Drupal" } ; String[] year = { "2012", "2013", "2014", "2015", "2016", "2017", "2018" } ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); list=(ListView)findViewById(R.id.list); list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, web));...

Color selector won't take normal color for my button

android,android-layout
I'm trying to programmatically add selector for background color of my button. And the problem is: my selector won't take color for normal state and except of that color just put a gray color for background. Note that when I use phone devices with api 16 the problem occurs. I...

Create Same Size Image Across Various Android Densities

android,android-layout,image-manipulation,android-image
My goal is to create 6 images of different densities that are the same size across the 6 generalized Android screen densities. From reading Android's documentation on supporting multiple screen sizes I understand the dpi unit (dots per inch) really represents physical pixels per inch. In my understanding, this means...

Android. Making my object appear anywhere on the screen

android,android-layout
If I want a bunch of objects that appear let's say middle, middle right and occupy have the ability to occupy any part of the screen, would I use gridlayout or relative layout and dp to customize the location? I think I explained it badly. If I used an analogy,...

How do I add a button to an Android Frame Layout, in the same position as my picture (centered in the bottom 4th of the screen)?

android,android-layout,android-button,framelayout
This is an Android question. How do I add a button to a frame layout, in the same location as my picture? I am trying to add a button on top of a frame layout (which has a background image and no title bar) like so: This is the entire...

Android Google Map in FragmentDialog being overlayed by the Dialog's own gray overlay

android,google-maps,android-layout,android-fragments,layout
I just migrated a MapView from an Activity's layout to a DialogFragment. It was a pretty painless migration: A button on the activity launches the dialog, setting the LatLng the map requires: case R.id.btn_open_map: android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); DirectionsMapDialogFragment mapDialogFragment = new DirectionsMapDialogFragment(); mapDialogFragment.setLatLng(mLatLng); mapDialogFragment.setRetainInstance(false); mapDialogFragment.show(fragmentManager, "fragmentName"); break; In the...

The specified child already has a parent. You must call removeView() on the child's parent first”

java,android,android-layout
I am trying to add a marginTop of 20 using Java if the Android Version is Kitkat or above. I am getting an error The specified child already has a parent. You must call removeView() on the child's parent first. I have tried these but to no avail. The specified...

Floating action button in ViewPager above a listView

android,android-layout,listview
I have a working floating action button inside of a LinearLayout currently. The LinearLayout it is inside of is in one tab of a SlidingTabLayout. I want the floating action button to be on top of the list view inside of the first tab, and also to show inside of...

Aligning layout to fit all screen size

java,android,xml,android-layout
This is my linear layout and i have achieved the following.. I want to consume full page height.So I am taking the weight of the layout.But images are getting stretched But the images are getting stretched.. I want to use the original width of the image.. What changes do...

Android SnackBar giving exception and not working

android,android-layout,android-design-library,android-snackbar
I have tried new Snackbar from the official design library provided by Google. I have downloaded new Design library through SDK and put it into libs folder. I am using eclipse and whenever I tried to run it it gives exception. I don't want to use any extra third party...

IllegalArgumentException:No view found for id

android,android-layout
I get the following exception: java.lang.IllegalArgumentException: No view found for id 0x7f04001a (com.whatever:layout/fragment_main) Looking at similar questions on SO: One answer suggests using getChildFragmentManager() instead of getSupportFragmentManager(). This is not an option since MainActivity is not a Fragment. Another answer suggests that fragment_main is not a child of activity_main, but...

Android: Fullscreen landscape Video with hideable Navigation Bar, but do not overlap the progress bar

android,android-layout
I'm trying to create a VideoPlayer. I'd like the user to have an immersive experience, with the option to use the NavigationBar upon user tap. void showNavBar() { activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE } void hideNavBar() { activity.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |...

Why are these buttons mis-aligned in a TableLayout?

android,android-layout
I'm using a table layout to arrange some buttons. As long as I use the same font for all the labels they are properly aligned in each row. For some buttons I'd like to use icons from a custom ttf font. When I use such an icon, the button is...

how to pass data intent in different textview in android

android,android-layout,android-intent
I have 3 activities layouts. In the first layout I want the user to input a number that had displayed (almost same with captcha) and in the second layout too. Next i want to pass the result to the last layout. Here is my code. firstlayout: EditText periksaAnsTxt = (EditText)...

put linearlayout under sliding drawer

android,android-layout,slidingdrawer
i have a linear layout and now i want to put all my content under sliding drawer (right to left sliding drawer). my linear layout is: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/mainpage" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:pj="http://schemas.android.com/apk/res/com.sha_ver1" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/safhe_asli" > <RelativeLayout android:layout_weight="0.5"...

How to fix the position of a view inside a ViewPager and CoordinatorLayout

android,android-layout,android-design-library,android-coordinatorlayout,coordinator-layout
I have an activity with the layout of: <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_height="56dp" android:layout_width="match_parent"...

Change background on FloatingActionButton?

android,android-layout,material-design
I am trying to set the background of a FAB to a different color in XML. I know I could do this in code, but that would also require a lot of inconvenient refactoring on my part. <android.support.design.widget.FloatingActionButton android:layout_width="40dp" android:layout_height="40dp" android:background="#F38E1B" android:id="@+id/fab"/> For some reason, the background stays blue when...

Positioning Cardviews below eachother not working

android,xml,android-layout
I'm trying to position a few Cardviews below eachother in a RelativeLayout, but it isn't working out so far. The cardviews are all on top of eachother, but layout_below is set for all of them. It's pretty strange, because it did work in the past if I recall correctly. <RelativeLayout...

RadioGroup and TextView in a RelativeLayout - RadioGroup is hiding TextView

android,android-layout,android-radiogroup
This is what am trying to accomplish. A textView and beneath that a radioButton group in which radioButtons are added programmatically. Am able to get only the radioButton group displayed with radioButtons and not the textView. radioButton group is taking up all the space in layout and textView is invisible....

Android ViewFlipper with translation animation - not working properly

android-layout,android-animation,translation,viewflipper
I want to display banner(images moving in x direction) in my application. For that i am using ViewFlipper with Translation animation. Please find my below code.. my layout: banner.xml <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" > <ViewFlipper android:id="@+id/banner_image" android:layout_width="match_parent" android:layout_height="258dp" /> </RelativeLayout> In...

Listview is not visible with other elements on top of it

android,user-interface,android-layout
I'm trying to create UI like the attached image. My xmal code below. There is one main issue that I"m running into. I understand that I can't embed a listview within a scrollview. The problem is, because of all the stuff on top of the listview, only a small portion...

android.view.InflateException: Binary XML file line #13: Error inflating class

android,xml,android-layout
I am facing the above error on an app that used to work fine as of few months ago, with no changes since then. The only change is updated Android studio/gradle The stacktrace 06-18 21:37:52.817 27995-27995/com.XYZ.carnival.debug E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.XYZ.carnival.debug, PID: 27995 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.XYZ.carnival.debug/com.XYZ.carnival.MainActivity}:...

How to inflate views programmatically in vertical order

java,android,android-layout
I just picked up Android developing. I decided to make a ToDo-list(simple and has a somewhat visual body) but I'm facing problems with inflating Layout in order. Basically I have an Activity that collects information that is supposed to be shown in Main Activity. I get one of them showing...

Avoid word wrap (and “…”) in long tab titles using ViewPager Tab [landscape]

android,android-layout,android-styles
How do I avoid word wrap and incomplete tab titles ( like the three '...') in Tabs using ViewPager See screenshot below: UPDATE When I set the following in styles.xml: <style name="MyTabTextStyle" parent="Base.Widget.AppCompat.ActionBar.TabText"> <item name="android:maxLines">1</item> <item name="android:width">80dp</item> </style> it partly works when I DO NOT ADD A LOGO in ActionBarStyle:...

Layout occupies more than desired

android,android-layout,relativelayout
I want an included RelativeLayout acts like footer but I don't get it like this and that's what I get. And that'S what I'd like to get. I copy my Layouts so that you can say me what I'm making wrong Main xml <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <RelativeLayout...

Android ScrollView not scrolling in Activity with Drawer Layout

android,android-layout,navigation-drawer,android-scrollview,drawerlayout
Let me introduce you to my activity: <RelativeLayout 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"> <include android:id="@+id/toolbar_actionbar" layout="@layout/toolbar_default" android:layout_width="match_parent" android:layout_height="wrap_content"/> <FrameLayout android:id="@+id/main_fragment_container" android:layout_width="match_parent"...

Android ImageView margins

android,android-layout,android-linearlayout
Creating layout and can not solve margins up and above the ImageView (and don't understand why they appear). Logo itself is without these margins. I use layout_width="250dp" the same as for the buttons. And layout_height="wrap content". Layout code is here: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/menu_background" android:gravity="center"...

Adding elevation to layout [closed]

android,android-layout
I have a custom listView and the list item that i am using is a linear layout with couple of images and text. Now i want to make this list item a bit elevated just like the pic below ...

How To Update a layout in onActivityCreated() of Fragment

android,android-layout,android-fragments,android-activity
I am inflating a layout in onCreateView() of the Fragment,On the Activity created() of the Fragment,I am retreving the data from the DataBase and updating the values in the layout from the DataBase which i inflated earlier. LinearLayout main = null; if (rootView instanceof LinearLayout) main = (LinearLayout) rootView; main.removeAllViews();...

ExpandableListView expanding over other layout

android,android-layout
I have this layout: <?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"> <LinearLayout android:id="@+id/details" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center" android:weightSum="1" android:visibility="visible"> <LinearLayout android:orientation="vertical"...

Android Full Width in Video View

android,android-layout,android-activity,videoview,android-videoview
I am trying to stretch my video view inside the linear layout or relative layout to full screen but the application does not stretches the width of the video view same to android screen. There is always 10 to 15 dp space on left and right each. Also the Linear...

ImageButton Not clickable - AndroidStudio

java,android,android-layout,android-studio
I have these declarations for 4 ImageButtons on my Android app, but so far they aren't clickable, this is my class: public class WelcomeScreen extends Activity { ImageButton completeprofile; ImageButton gotoportfolio; ImageButton findfriends; ImageButton readnews; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.welcome_activity); completeprofile = (ImageButton) findViewById(R.id.completeprofile); gotoportfolio = (ImageButton) findViewById(R.id.gotoportfolio);...

setBackground null pointer exception

android,android-layout
im trying to set background to my activity but it throws nullpointer exception everytime here is my code super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); RelativeLayout layout = (RelativeLayout) findViewById(R.layout.activity_main); layout.setBackground(getResources().getDrawable(R.drawable.welcome_2)); if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { layout.setBackgroundDrawable( getResources().getDrawable(R.drawable.welcome_1) ); } else {...

How can I change ImageButton size programmatically?

android,android-layout,android-imagebutton
I'm generating ImageButtons programmatically and I'm not able to change the size of the items using XML. So, I would like to do it programmatically too. How can I do that? My code : String[] separated = result.split("%"); ImageButton [] txt =new ImageButton[20]; for(int i=0;i<txt.length;i++) { String getname = separated[i];...

Project has no project.properties file! Edit the project properties to set one and already error when create any project

android,android-layout,android-activity
There are many answers on this question on this site but i think non of them are work with me and here's errors: [2015-06-13 19:37:02 - appcompat_v7] Project has no project.properties file! Edit the project properties to set one. [2015-06-13 19:37:02 - appcompat_v7] Project has no project.properties file! Edit the...

How can I fix the spinner widget at the top of the page in adroid?

android,android-layout,spinner
I am using a spinner for drop down in my android app. But, problem is when user scrolls down, the spinner moves up and becomes invisible. I want to fix the spinner at the top of the page so that user can easily select the page. Here with Scrollbar: On...

How to check weather the indirect child exists in View or not?

android,android-layout,view
Here is my layout. <LinearLayout android:id="@+id/lyt_linearNative" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:visibility="gone" > <LinearLayout android:id="@+id/lyt_tp1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageView android:id="@+id/vmax_iv_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/bee7_btn_close" />...

How to add a text with image with exactly half in the layout in android?

android,android-layout
I have a text in a linear layout android. Below that text I should keep two button exactly half with arrows at the end of the button. I am trying for this with various ways but I am not able to place the arrows correctly to both corners. Please help...

Bottom 96 Pixels of Nexus 4 Screen Missing - Get Window Dimensions for Nexus 4

android,android-layout,nexus-4
I am working on an application that has contains a RelativeLayout within the main.xml. Additional ChildViews are added to the RelativeLayout dynamically through onclick events. When I run the application, the displayHeight retuned for my nexus 4 is 1184 although it should be 1280. Essentially, the height of the screen...

I want to Show Simple Toast Message When User Click On Media Controller button Pause/Start/Stop in video View Using Media Controller

android,android-layout,android-intent,android-fragments,android-activity
My Java Code and I know How To Play / Stop / Pause Video videoView=(VideoView)findViewById(R.id.videoView); // Video from raw Folder mediaController = new MediaController(this); uri = Uri.parse("android.resource://" + getPackageName() + "/"+ R.raw.abc); videoView.setVideoURI(uri); mediaController.setMediaPlayer(videoView); videoView.setMediaController(mediaController); videoView.requestFocus(); videoView.start(); ...

Why can't ListView be top level view?

android,android-layout,listview
So to create a Fragment which contains a single ListView, I must do <FrameLayout 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"...

Ending multiselect in a listview removes list item padding

android-layout,android-listview,recyclerview,android-4.1-jelly-bean
I can only reconstruct this behavior with a JellyBean device (Android 4.1.2 on a Samsung Galaxy S3). With KitKat or Lollipop this problem did not occur. I have a RecyclerView with a list of items which possible multiselect. When I select a few items in the list (the multiselect gets...

Android RelativeLayout placing 2 views next to eachother one view is variable?

android,android-layout
I am looking at placing 2 views next to each other. 1 View has a fixed width while the other should take up the rest of the space (variable). I have currently set the layout with the fixed width view with the alignParentRight="true" that is fine however it overlaps the...

How would I make a grid layout occupy 1/2 of a screen?

android,android-layout
My current thinking is to use a horizontal LinearLayout with 1/2 as the Weightsum but that does not make the Linearlayout occupy 1/2 of the screen (which would have allowed me to place a Gridlayout on top). How would I make the Gridlayout occupy the upper 1/2 of the screen?...

How do I make a textview fill the height of a linear layout?

android,android-layout,textview
Ok, I've been spending hours trying to solve this or even find a solution online and so far nothing has worked. How can I make the TextView "content_note" fill the available space in this LinearLayout? <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"...

Application Unfortunately stopped when going from 2nd activity to 3rd activity

android,android-layout,android-activity,android-studio
I'm new to Android developing. This is an assignment which was given to me. I have to convert the value and the converted value must be shown in the next activity. But when I press the submit button its crashes.I don;t know what is the problem. Is there a problem...

Configure CoordinatorLayout from code

android,android-layout,android-coordinatorlayout
I'm dynamically injecting a content view into the CoordinatorLayout and would now like to apply a layout_below property to the injected view so that it isn't hidden behind the AppBar. Is there any way to do this at runtime from code instead of xml properties of the annotation?...

Android compiles but crashes

java,android,android-layout,listview,android-intent
i am trying to develop my first app. It compiles and installs but crashes when I open it. Here is the Code public class MainActivity extends ActionBarActivity implements OnItemClickListener { private ListView listview; private DrawerLayout drawerlayout; private ActionBarDrawerToggle drawerListener; private LinearLayout menu; private myAdapter myadapter; @Override protected void onCreate(Bundle savedInstanceState)...

Difference between preference fragment and “regular” fragment

android,android-layout,android-fragments,robolectric
I am attempting to write some tests to "assert" the headers of my settings app are being properly built. The settings app was built by someone else so I am attempting to understand their code before doing anything. They used "Preference Fragments" in this app. what is the difference between...

Android Toolbar Action button height

android,android-layout,appcompat,android-toolbar
I have res/layout/toolbar.xml which is: <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?actionBarSize" android:elevation="4dp" style="@style/ToolbarStyle"> </android.support.v7.widget.Toolbar> Here is my usage of toolbar: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"...

Difference between match-parent and fill-parrent [duplicate]

android,android-layout
This question already has an answer here: What is the difference between match_parent and fill_parent? 7 answers For so long im trying to understand the difference between match-parent and fill-parrent can any please explain it ...

Set portrait only orientation on devices with a screen size of less than 7 inches

java,android,android-layout,android-activity,android-orientation
I am creating an android application that I want to: Run portrait only orientation on screen sizes (6.9"-) Run portrait and landscape orientations on screen sizes (7"+) How would I declare this without using androids deprecated (small, normal, large, xlarge) screen sizes?...

Error:(1) Error parsing XML: not well-formed (invalid token)

android,xml,android-layout,xml-parsing
On right clicking the error "Error:(1) Error parsing XML: not well-formed (invalid token)" and then jump to source it opens the following activity_main.xml. I am not able to figure the error out <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" tools:context="com.example.utkarsh.beatle.app.MainActivity" android:layout_width="match_parent" android:layout_height="match_parent" tools:ignore="MergeRootFrame"/> Andoridmanifest.xml <?xml...

titanium tableview font color

android,android-layout,titanium,tableview
How to change the font-color in a TableView. Other elements can be changend with the color attribute. When i run the app on my Android Phone the table is displayed, but the font-color is still grey/white. There are also no table borders. I want to set the color to black....

Inflating ImageButton programatically changes width & height params to wrap_content. Why?

android,android-layout,android-inflate,layoutparams
In my app I'm using android.support.v7.widget.Toolbar. Left half of the toolbar always acts as back button. Right half is different for different activities. Sometimes it's just text, sometimes a button. So I inflate the right half with views programmatically. Toolbar <android.support.v7.widget.Toolbar> ... ... <LinearLayout android:id="@+id/left_LL"/> ... <LinearLayout android:id="@+id/right_LL" android:layout_width="wrap_content" android:layout_height="wrap_content"...

Set text color to secondary color programmatically

java,android,android-layout,android-textview
How can I set the color of my text to "textColorSecondary" programmatically? I've tried the code below but it doesn't work. Does anyone know what's wrong with the code? TextView tv1 = ((TextView)v.findViewById(R.id.hello_world)); tv1.setTextColor(Color.textColorSecondary); ...

marquee text of textview in actionbar not marquee anyone after setText

android,android-layout,android-textview
I have a ActionBar with a TextView <?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="50dp" > <TextView android:id="@+id/title_text" android:text="This will run the marquee animation forever" android:textSize="@dimen/abc_text_size_title_material_toolbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="marquee"...

ImageView in CollapsingToolbarLayout not covering full height?

android,android-layout,android-design-library,androiddesignsupport
I have some issues trying to implement the new CollapsingToolbarLayout. Scrolling, expanding and collapsing do work fine, but my ImageView (no matter what type of resource I set) does not cover the full height of the expanded toolbar. See here: Here I set android:src="@color/red" on the image view, but it...

Android layout: how position layout children at center of the screen?

android,android-layout
My goal is to have the form with background white at center of the screen. Just followed some other answer on SO but I cannot achieve my goal. Only if I remove the background white the Layout goes at center. But, I have the image on background, so I need...

How can create a andorid Layout with two layout with ListView

android,android-layout,listview,button
I can not set properly for the andorid layout! On my code the listview It fills the screen. If I change the layout_height on the listview with a number not good for all resolutions! I use this code: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/FirstLinearLayout"...

Update Action Bar Style Using Theme AppCompat Light

android,android-layout,android-fragments
I am trying following in style file but unable to change font and text position of action bar. I want to do it in my style sheet. <resources> <!-- Base application theme. --> <!-- Theme.AppCompat.Light.NoActionBar, Theme.Holo.Light --> <style name="AppTheme" parent="Theme.AppCompat.Light"> <!-- Customize your theme here. --> <item name="android:windowBackground">@color/white</item> <item name="colorPrimary">@color/green</item>...

Custom editText on android

android,android-layout,android-edittext,frontend,android-custom-view
I'm newbie with android layout, so i need some help. I want create a custom editText, something like this: I'm want to fix that with the best possible way. Someone? Thanks....

Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference

android,android-layout,android-intent,android-activity
Unable to pass data from one fragment to another using intent. Logic is fine .Please check the last parts of main activity where I have sent strings to other activity using putExtra. Here is the MainActivity.java : public class MainActivity extends Activity implements View.OnClickListener { EditText ed1,ed2,ed3,ed4,ed5,ed6; Button bt1; TextView...

Fragment not appearing properly in two pane tablet mode

java,android,xml,android-layout,android-fragments
I'm trying to launch my fragment in the detail fragment & highlight the selected list item (code is there in FragmentWCLine.java) in two pane mode but for some reason it won't do so. Seems to work fine in single pane mode but when it comes to two pane mode it...

Change layout of EditText on state “selected”

android,android-layout,android-edittext,drawable,android-drawable
I am trying to obtain a EditText changing it's colors and layout when the user clicks on it to type something, and I do that with a custom drawable, but the attributes android:state_enabled="true" android:state_focused="true"> don't work at all, meaning that they don't get called. EditText: <EditText android:id="@+id/field_user_info" android:hint="Nome e Cognome"...

How to create a layout which is rounded on all sides?

android-layout,android-linearlayout
I have created a layout which is supposed to have rounded corners on all the four sides. However, the layout shows rounded corners only in the left and right top corners. How to create a layout which has rounded corners on all the four sides (including the left and right...

TabLayout color of selected tab underline

android,android-layout
How can I change the color of the underline of the selected tab on the new TabLayout? The PagerTabStrip has a method setTabIndicatorColor(int color), TabLayout doesn't seem to have such a method. ...

How to make image distributed to screen width in RelativeLayout?

android,android-layout,relativelayout,android-relativelayout
I have three icon the a RelativeLayout, how to make them distributed to screen width? Since I may add more icon to this line programmatically, I cannot hard code a fixed margin to these icon. <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="50dp" android:layout_height="50dp" android:id="@+id/icon1" android:src="@mipmap/icon" /> <ImageView android:layout_width="50dp" android:layout_height="50dp" android:id="@+id/icon2" android:layout_toRightOf="@id/icon1"...

Dealing with Fragment and listView and JSON

android,android-layout,android-intent,android-fragments,android-activity
I am trying to make an application with MenuDrawer that contains 4 fragments. This is how my application show do. When it starts, it should retrieve data from a website. The retrieved data should be in a listview in the first fragment. The second fragment should contain a webview to...

Spinner Dropdown Arrow

android,android-layout,spinner
I am trying to obtain a custom Spinner such as this one: but I was only able to get this: As you can see I experience several problems. Although I added a custom arrow, I still see the original. My custom arrow gets shown at every row. How do I...

Android dialog is compressed

android,android-layout,android-dialog
I am using a layout to show dialog. In my xml design it is perfect but when i open it in the app, it is scrambled.. Below are the screen shots: The xml file design: And the dialog in mobile: my xml code is: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"...

Align the text of a button to the bottom

android,android-layout,android-button
I am facing a problem. I want to align the text of a button to the bottom with a padding of 20dp. However, the text sticks at the bottom of my button. <Button android:id="@+id/CatButton" android:layout_width="match_parent" android:layout_height="150dp" android:paddingBottom="20dp" android:background="@drawable/rounded_1_selected" android:gravity="bottom|center_horizontal" android:text="test"/> Can anyone please help me?...

Creating a custom layout without the App action/status bar in Android

android,android-layout
For starters any app created in the IDE comes with an App header, how could I go about creating a layout without the action bar?

Android layout design: composite Relative vs fragments

android,android-layout,listview,android-fragments,android-listfragment
I want a simple scrollable ListView. I have a custom adapter that makes each row display a picture and some text. Underneath I want a few buttons. I'm looking for a layout like this sample picture: This seems like it should be trivial. I have a single main activity that...

When putting listview inside a RelativeLayout it always looking for R.id.list

android,android-layout,listview,android-listview
I was trying to put an imageview and a listview inside a relative layout, but i'm always having an error like this Your content must have a ListView whose id attribute is 'android.R.id.list' then i tried just putting ListView as the parent and it works but i want to display...

Android Resize imageView to fullscreen with orientation

android,xml,android-layout
I have an xml that contains a imageview and I would like that when clicked, it is resized to the size of LinearLayout taking into account the orientation of the image. And then at a click, replace the image by default. My Xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout...

Setting Content in a EditText

java,android,xml,android-layout
I am developing a android calculter and I want to add the number the user clicks when he clicks its button i added the onclick like this android:onClick="number(1)" the number inside the brackets is the number that i want it to be appended inside the EditText and the code of...

Button weight in linear layout

android,android-layout,android-layout-weight
This the code I have <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:weightSum="1"> <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0.75"> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:layout_width="wrap_content"...

OnClick on inflated items

android,android-layout,android-inflate
In my activity.xml I have a LinearLayout. This LinearLayout contains an inflated layout consisting of four ImageViews. Implementation is something like this: LinearLayout linearLayout = (LinearLayout) findViewById(R.id.ll_template); View view = getLayoutInflater().inflate(R.layout.inflated_layout, linearLayout, false); linearLayout.addView(view); I want to implement an action if the user clicks on the image. However, nothing happens...

Android button default background

android,android-layout,material-design,android-styles
I know that I can set the background of my button by using a custom drawable like this: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" > <shape> <gradient android:startColor="#ffffff" android:endColor="#ffffff" android:angle="270" /> </shape> </item> <item android:state_focused="true" > <shape> <gradient android:endColor="#ffffff" android:startColor="#ffffff" android:angle="270" />...

Accessing shared preferences in a non-activity class from fragment class

java,android,android-layout,android-fragments
I have a fragment: public class TodayVerse extends Fragment { TextView textView; DailyQuranMethods dailyQuranMethods; public TodayVerse() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_today_verse, container, false); textView = (TextView) view.findViewById(R.id.verse);...

Why elements adding at the end of ListView?

android,android-layout,android-listview,android-adapter
I am working with custom ListView. Why items were added to the end of list view? I have only 3 items. 15000.00 is added first (so it is not reversed). ...