Try this :
//the layout on which you are working
LinearLayout layout = (LinearLayout) findViewById(R.id.linear_layout_tags);
//set the properties for button
Button btnTag = new Button(this);
btnTag.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
//add button to the layout
- How to define dimens.xml for every different screen size in android?
- Can the Android layout folder contain subfolders?
- How to build a horizontal ListView with RecyclerView
- How to display count of notifications in app launcher icon [duplicate]
- Android: alternate layout xml for landscape mode
- Why does LayoutInflater ignore the layout_width and layout_height layout parameters I’ve specified?
- How to customize a Spinner in Android
- How to layout text to flow around an image
- Nested Recycler view height doesn’t wrap its content
- RecyclerView: Inconsistency detected. Invalid item position
- Outlined Edit Text from Material Design
- How to dismiss the dialog with click on outside of the dialog?
- How to set layout_weight attribute dynamically from code?
- Why should we use xml layouts?
- How do I change the android actionbar title and icon
- How to change the color of a CheckBox?
- Pop up window over Android native incoming call screen like true caller Android app
- Remove icon/logo from action bar on android
- Unresolved reference – activity does not recognize synthetic imports in android studio v4
- LinearLayout not expanding inside a ScrollView
- How to detect the swipe left or Right in Android?
- Programmatically adding TableRow to TableLayout not working
- How to center icon and text in a android button with width set to “fill parent”
- Adding button action in custom notification
- How to use View.OnTouchListener instead of onClick
- Centering RecyclerView items with FlexboxLayoutManager
- Android Studio – TextView not showing in design view layout
- Android DisplayMetrics returns incorrect screen size in pixels on ICS
- How to create android spinner without down triangle on the right side of the widget
- How to add (vertical) divider to a horizontal LinearLayout?
- Get height and width of a layout programmatically
- Place ImageView over Button android
- Android-L CardView Visual Touch Feedback
- How can I align Android Toolbar menu/icons to the left like in Google Maps app?
- Adding content to a linear layout dynamically?
- android get activity returns null
- move up text view only when virtual keyboard open on android
- MPAndroid Chart not displaying any labels for xAxis , what is missing?
- Android and setting alpha for (image) view alpha
- application content goes behind the navigation bar in android L
- Create Custom Big Notifications
- Which view should be used for new Material Design Bottom Navigation? [duplicate]
- Android supporting multiple resolution with multiple layout folder
- Is it possible to put a ConstraintLayout inside a ScrollView?
- Defining a percentage width for a LinearLayout? [duplicate]
- Dynamically creating Buttons and setting onClickListener
- onListItemClick is not working for listview?
- Show entire bottom sheet with EditText above Keyboard
- Android Layout: Horizontal Recyclerview inside a Vertical Recyclerview inside a Viewpager with Scroll Behaviors
- In android layouts what is the effect/meaning of layout_height=”0dip”