How to make a nice Main Menu Page - xamarin

I want to make a nice Main Menu Page like the home page of Android Device in which the button images are layout in rows; each row in a page say contain 4 imageButtons.
I used the below layout, but the imageViews in each rows are not evenly size. I have these questions:
I want to have 3 imageView in a row.
How to detect What is the Width and Height of a screen, so divide it for 3 imageView? say, base on galaxy note.
How to do spacing among the 3 imageViews? Below each ImageView there is a textView to indicate the name or function of the ImageView.
Should I allow rotate? if rotate , how to enable scrolling when rotate to horizontal?
Thanks
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/myLinearLayout"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/poiImageView"
android:id="#+id/linearLayout1"
android:layout_centerVertical="true">
<ImageView
android:id="#+id/Thumbnail1"
android:layout_width="70dp"
android:layout_height="70dp"
android:paddingLeft="10dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="#drawable/Icon" />
<ImageView
android:id="#+id/Thumbnail1a"
android:layout_width="70dp"
android:layout_height="70dp"
android:paddingLeft="10dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="#drawable/Icon" />
<ImageView
android:id="#+id/Thumbnail1b"
android:layout_width="70dp"
android:layout_height="70dp"
android:paddingLeft="10dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="#drawable/Icon" />
</LinearLayout>
<LinearLayout>
2nd row
</LinearLayout>
<LinearLayout>
3rd row
</LinearLayout>
</LinearLayout>

I believe you're looking for GridView. GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid. It handles scrolling by itself when content grows. Additionally you will get additional features packed such as memory handling, inbuilt MVC using adapter pattern etc.
A simple GridView looks as follows;
<GridView
android:id="#+id/gridView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:columnWidth="100dp"
android:drawSelectorOnTop="true"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="5dp"
android:focusable="true"
android:clickable="true"/>
You can checkout some complete GridView implementation from the following links.
Android GridView Example- Building Image Gallery in android
Download and Display Image in Android GridView

Related

Android Studio,ImageView,shows different size image in different size's mobile

created an android app which loads pics in ImageView randomly from drawable folder by .setImageResource,but the main problem is image it loads shows correct size image but in different size mobile shows different size image,also in some mobile it covers the screen which hides the buttons etc,
its works fine in my Redmi 2 Prime which is 4.7nch,resolution:720*1280,
but in Samsung Galaxy Grand Neo its hides the entire screen with that image i.e screen size: 5.01 inch
resolution: 480*800
Samsung grand neo screenshot  
Redmi 2 screenshot
<?xml version="1.0" encoding="utf-8"?>
<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:background="#4e2f22"
tools:context="com.wordpress.dragontelnetsite.mindreader.SecondActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#drawable/backg">
<Button
android:layout_width="140dp"
android:layout_height="wrap_content"
android:text="Next"
android:id="#+id/button2"
android:onClick="clickedOnPlay2"
android:background="#4cb076"
android:layout_marginBottom="60dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<ImageView
android:layout_width="310dp"
android:layout_height="350dp"
android:id="#+id/chart"
android:scaleType="fitXY"
android:src="#drawable/c1"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>

how to set width, heigh icon on toolbar on xamarin android

Main.axml
?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- your content layout -->
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:titleTextColor="#android:color/background_light" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</RelativeLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:id="#+id/nav_view"
app:headerLayout="#layout/drawer_header"
app:menu="#menu/navmenu" />
</android.support.v4.widget.DrawerLayout>
<item
android:id="#+id/menu_share"
android:icon="#drawable/ic_search_white_48dp"
android:showAsAction="ifRoom"
android:title="Search"
/>
</menu>
public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
{
MenuInflater.Inflate (Resource.Menu.Action_menu, menu);
return base.OnCreateOptionsMenu (menu);
}
I saw that icon's very big. if I set a icon smaller then it don't show clearly icon. So I want to set a big icon but it be set width and heigh smaller.
About width=20dp and heigh too.
The standard icon size for Toolbar items on android is 24dp as described in the Material Icons Guide and in the Icons style guidelines from Google (see clearance section).
So make sure to scale your icon to that size outside of the app or find an icon which has the correct size. Google's own Material Design Icons are a good place to find such icons scaled to the sizes you need.
Alternatively, with Vector Drawables being supported in Android M and in the AppCompat libraries, then you could look into converting your icons into Vector images instead. This will save a lot of space in the app and make them nicely scalable.

Android custom view renders slowly

//How app should function
I am writing an android app where I am trying to display 6 'information cards' arranged in a 2 card X 3 card grid (rows x columns) which is inside of a viewpager in my home activity. When the activity starts the user will see 6 cards arranged in a grid. They will be able use a swiping motion which will cause the original 6 cards to slide off of the screen and another 6 cards will slide onto the screen.
//Card details
The cards themselves are sort of like a form in the sense that each card has the same information fields, but each card will have different information in each field (e.g. there is a textView for each card that displays the name of the card, but each card has a different name displayed in the textview). To accomplish this I have created a card class that inflates an XML layout of the card and then populates each textView, imageView, etc... with information that is custom to each card. This view is then added as a Fragments's view so each card displayed on the screen is actually a Fragment and is displayed in my 2 X 3 grid which is also a fragment which is inside of a viewpager. So, I have a card Fragments which are placed into another grid Fragment which used as a page for the ViewPager. Also, the cards are flippable so they have a front and a back. I am using a single layout file to create a front side and back side for the cards. I selectively show / hide the front layout or back layout when I want to show either the front or back of the card.
//The problem
My problem is that when the app starts up there is a 6 - 10 second lag (using a Galaxy Tab 10.1 and Nexus 7) while I wait for the cards to render. All of the card data is local, so I know I am not waiting for a web service to return data, I definitely have the data on hand and ready to use. I believe that the lag time is probably due to the fact that I have to render these cards which consist of many layouts and widgets. Also, at runtime I never know how many cards I will need to render, so I am always creating instances of the card fragments programatically.
//Things I've investigated
Because I am creating the cards as fragments one thing that I have tried is to replace the card fragments with different fragments that have simpler layouts. I found that the render speed increased to an acceptable level using fragments that have simpler layouts.
//My question
I'm at a point where I don't really know what to try to decrease the amount of time it takes to render the screen with the cards. I am trying to make my XML layout for the cards as simple as possible, but at some point I can't simplify them anymore without compromising the design of them. I am looking for suggestions on how it might be possible to render layouts with lots of widgets without seeing the performance hit that I'm seeing. Are there any tips or tricks for rendering complex layouts? Could defining my cards completely programmatically (no XML layout) help? Any blatant errors that you can see?
Any help would be appreciated. Thanks!
//XML layout for the cards
<?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"
>
<RelativeLayout
android:layout_width="257dp"
android:layout_height="343dp"
android:id="#+id/cardContainerRL"
android:layout_centerInParent="true">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/cardFrontRL">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/frontUpperRL"
android:layout_weight="1"
android:focusable="false"
android:background="#drawable/card_top_note">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:id="#+id/frontHeader">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Waiting to be completed"
android:id="#+id/frontStatusTV"
android:layout_alignParentTop="false"
android:singleLine="false"
android:layout_centerInParent="true"
android:textSize="12dp"/>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/frontStarIV"
android:src="#drawable/cool_star"
android:adjustViewBounds="true"
android:layout_toLeftOf="#+id/frontStatusTV"
android:layout_centerVertical="true"
android:longClickable="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:id="#+id/numMessagesTV"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginRight="2dp"/>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Walk the Dogs Yo!"
android:id="#+id/frontTaskTV"
android:layout_below="#+id/frontHeader"
android:layout_marginTop="5dp"
android:layout_centerHorizontal="true"
android:textSize="22dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/frontLowerRL"
android:layout_weight="1"
android:focusableInTouchMode="true"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageClip"
android:background="#drawable/card_bottom">
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/cardImageIV"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="4dp"
android:src="#drawable/bulldog"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
</RelativeLayout>
</LinearLayout>
<TextView
android:layout_width="77dp"
android:layout_height="77dp"
android:text="666"
android:id="#+id/cardPointsTV"
android:layout_centerInParent="true"
android:singleLine="true"
android:background="#drawable/points_circle"
android:gravity="center_vertical|center_horizontal"
android:textSize="24dp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Due on Sat. Nov 13"
android:id="#+id/frontDateTV"
android:layout_above="#+id/cardPointsTV"
android:layout_centerHorizontal="true"
android:textSize="15dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="#+id/cardBackLL">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/backUpper"
android:layout_weight=".65"
android:background="#drawable/card_top">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="#dimen/back_header_height"
android:id="#+id/backHeader"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true">
<ImageView
android:layout_width="#dimen/back_star_width"
android:layout_height="#dimen/back_star_width"
android:id="#+id/backStarIV"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="false"
android:src="#drawable/cool_star"
android:scaleType="fitXY"
android:layout_marginLeft="#dimen/back_star_margin_left"
android:layout_centerVertical="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="To be completed"
android:id="#+id/backStatusTV"
android:layout_centerVertical="true"
android:singleLine="false"
android:textSize="#dimen/back_status_font_size"
android:layout_marginLeft="#dimen/card_back_detail_text_margin_left"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="false"
android:layout_alignParentBottom="false"
android:layout_marginRight="#dimen/card_back_points_container_margin_right">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="POINTS"
android:id="#+id/POINTS"
android:layout_alignParentRight="true"
android:textSize="#dimen/back_card_points_font_size"
android:layout_weight="1"
android:gravity="bottom"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="666"
android:id="#+id/backPointsTV"
android:layout_alignParentRight="true"
android:textColor="#color/dark_gray"
android:layout_alignParentBottom="true"
android:textStyle="bold"
android:textSize="#dimen/back_card_point_value_font_size"
android:layout_weight="1"
android:gravity="top"/>
</LinearLayout>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Walk the Dogs Yo!"
android:id="#+id/backTaskTV"
android:layout_below="#+id/backHeader"
android:phoneNumber="true"
android:textSize="#dimen/card_back_taskname_font_size"
android:textIsSelectable="false"
android:layout_marginLeft="#dimen/card_back_detail_text_margin_left"
android:maxLines="2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DUE ON"
android:id="#+id/dueOnTV"
android:layout_alignLeft="#+id/backHeader"
android:layout_alignParentBottom="true"
android:textSize="12dp"
android:textIsSelectable="false"
android:layout_marginLeft="#dimen/card_back_detail_text_margin_left"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sun. May 14"
android:id="#+id/backDateTV"
android:textSize="12dp"
android:textStyle="italic"
android:layout_toRightOf="#+id/dueOnTV"
android:layout_alignTop="#+id/dueOnTV"
android:layout_marginLeft="4dp"
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/backLower"
android:layout_weight=".35"
android:background="#drawable/card_bottom">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="49dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
<ImageView
android:layout_width="#dimen/back_button_width"
android:layout_height="#dimen/back_button_height"
android:id="#+id/backArrowIV"
android:layout_alignParentLeft="true"
android:src="#drawable/btn_back"
android:layout_centerVertical="true"
android:layout_marginRight="#dimen/arrow_button_margin_right"
android:scaleType="fitXY"/>
<view
android:layout_width="#dimen/back_buttons_width"
android:layout_height="#dimen/back_buttons_height"
class="com.android.ui.widgets.ActionButton"
android:id="#+id/editButton"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="#dimen/send_button_margin_right"/>
<view
android:layout_width="#dimen/back_buttons_width"
android:layout_height="#dimen/back_buttons_height"
class="com.android.ui.widgets.ActionButton"
android:id="#+id/sendMessageButton"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/editButton"
android:layout_marginRight="#dimen/edit_button_margin_right"/>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
With no offence you really need to review your layout.
Much more complicated views can be created with layouts 5-10 times lighter than this one.
You have:
<RelativeLayout> <!-- DISPATCH MEASURE LAYOUT DRAW -->
<RelativeLayout> <!-- DISPATCH MEASURE LAYOUT DRAW -->
<RelativeLayout> <!-- DISPATCH MEASURE LAYOUT DRAW -->
<LinearLayout> <!-- DISPATCH MEASURE LAYOUT DRAW -->
<RelativeLayout> <!-- DISPATCH MEASURE LAYOUT DRAW -->
<RelativeLayout"> <!--DISPATCH MEASURE LAYOUT DRAW -->
<TextView/> <!-- MEASURE LAYOUT DRAW -->
<ImageView/> <!-- MEASURE LAYOUT DRAW -->
<TextView/> <!-- MEASURE LAYOUT DRAW -->
</RelativeLayout>
<TextView/> <!-- MEASURE LAYOUT DRAW -->
</RelativeLayout>
<RelativeLayout> <!-- DISPATCH MEASURE LAYOUT DRAW -->
<RelativeLayout> <!--DISPATCH MEASURE LAYOUT DRAW -->
</RelativeLayout>
<ImageView/> <!-- MEASURE LAYOUT DRAW -->
</RelativeLayout>
</LinearLayout>
<TextView/> <!-- MEASURE LAYOUT DRAW -->
<TextView/> <!-- MEASURE LAYOUT DRAW -->
</RelativeLayout>
<LinearLayout> <!-- DISPATCH MEASURE LAYOUT DRAW -->
<RelativeLayout> <!-- DISPATCH MEASURE LAYOUT DRAW -->
<RelativeLayout> <!-- DISPATCH MEASURE LAYOUT DRAW-->
<ImageView/> <!-- MEASURE LAYOUT DRAW -->
<TextView/> <!-- MEASURE LAYOUT DRAW -->
<LinearLayout> <!-- DISPATCH MEASURE LAYOUT DRAW -->
<TextView/> <!-- MEASURE LAYOUT DRAW -->
<TextView/> <!-- MEASURE LAYOUT DRAW -->
</LinearLayout>
</RelativeLayout>
<TextView /> <!-- MEASURE LAYOUT DRAW -->
<TextView /> <!-- MEASURE LAYOUT DRAW -->
<TextView /> <!-- MEASURE LAYOUT DRAW -->
</RelativeLayout>
<RelativeLayout> <!-- DISPATCH MEASURE LAYOUT DRAW -->
<RelativeLayout> <!-- DISPATCH MEASURE LAYOUT DRAW -->
<ImageView /> <!-- MEASURE LAYOUT DRAW -->
<view /> <!-- MEASURE LAYOUT DRAW -->
<view /> <!-- MEASURE LAYOUT DRAW -->
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Even parsing this layout will take some time on small devices. And this is only for creation, I don't wanna think about dispatching touch events with a view hierarchy like this.
If you really cannot come out with a lighter layout.
You can:
Optimizing Your UI
Profiling with Traceview and dmtracedump - If you really think
your problem is not the hierarchy, but trust me on this one.
Create MyCardsView and MyCardView writing some quality code and watch
the app fly: Creating Custom Views
Cheers,
Sam.
Source: Google and years of experience in Android development.

Avoid repetition of view in android gridview

I am stuck at gridview.
I want an imageview below Gridview to handle click event of that.
Basically what i need is when click on this imageview button(here imageView_uparrow) it will slide up the layout which contains this gridview,
but when I add imageview(imageView_uparrow) below gridview(imageView_uparrow) in xml and run the project; gridview repeats that imageview on every grid icon.
I want that imageview to be appeared once at the bottom. Here is my XML.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top" >
<GridView
android:id="#+id/inside_gridView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:layout_marginTop="58dp"
android:alpha="0.1"
android:background="#696969"
android:columnWidth="10dp"
android:gravity="center"
android:numColumns="3"
android:padding="4dp"
android:scrollbars="vertical"
android:stretchMode="columnWidth" >
</GridView>
<ImageView
android:id="#+id/image_insidegrid"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_margin="5dp"
android:contentDescription="#string/hello_world" />
<ImageView
android:id="#+id/imageView_uparrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="22dp"
android:layout_marginRight="20dp"
android:contentDescription="#string/hello_world"
android:src="#drawable/drop_down_top_arrow" />
</RelativeLayout>
Last imageview i.e imageView_uparrow keep on repeating with the gridview items.
Please help me with this.. Thanks in advance.!
Hey I got the solution..
i kept my imageView_uparrow in separate xml and image which i used to set as an icon of my grid separate xml.And just inflated and added that to the Layout.
My modified Grid Xml is here
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:id="#+id/parentRel"
>
<GridView
android:id="#+id/inside_gridView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:layout_marginTop="42dp"
android:background="#drawable/transperant_background"
android:gravity="center"
android:numColumns="3"
android:padding="0dp"
android:scrollbars="vertical"
>
</GridView>
</RelativeLayout>
This is my xml file for ImageView(imageView_uparrow).
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_up_arrow_for_gridView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageview_up_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="14dp"
android:contentDescription="#string/app_name"
/>
</RelativeLayout>
Code i use to inflate
Context context;
RelativeLayout rel;
ImageView upArrowImage;
LayoutInflater inflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
context=this;
View grid2;
rel=(RelativeLayout)findViewById(R.id.parentRel);
animate = AnimationUtils.loadAnimation(this, R.anim.slide_up);
animate.setAnimationListener(this);
LayoutParams lp = new LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(14, 400, 0, 20);
grid2=new View(context);
grid2=inflator.inflate(R.layout.gridview_up_arrow_button,null);
upArrowImage=(ImageView)grid2.findViewById(R.id.imageview_up_arrow);
((ViewGroup)upArrowImage.getParent()).removeView(upArrowImage);
rel.addView(upArrowImage);
upArrowImage.setImageResource(R.drawable.drop_down_arrow4);
upArrowImage.setLayoutParams(lp);

set the size of textbox with wrapcontent

This is the part from my layout
<LinearLayout android:orientation="vertical"
android:layout_height="wrap_content" android:layout_below="#id/checkBox_block_all"
android:id="#+id/linearLayout_addtoblack" android:layout_width="fill_parent">
<LinearLayout android:id="#+id/linearLayout2"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:gravity="center">
<LinearLayout android:id="#+id/linearLayout3"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:orientation="vertical" android:layout_weight="1">
<TextView android:id="#+id/textView1"
android:layout_height="wrap_content" android:text="Enter the full number"
android:layout_width="fill_parent"></TextView>
<EditText android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/editText1"
android:textSize="18sp">
<requestFocus></requestFocus>
</EditText>
</LinearLayout>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/button_add"
android:text="Add to black list" android:layout_weight="1"></Button>
</LinearLayout>
</LinearLayout>
and this is the image of how it looks like
The point is I want the textbox to be bigger, I set the height with value wrap_parent and I expect that the textbox will be big enough , but is not like that, the textbox as you can see is somehow cropped and I do not know why, any help , advice , anything ?, the point I do not want to set fixed values for the height of the textbox
In the "Add to black list" button, change the layout_height to "fill_parent"
The button is making the edittext smaller because their baseline is lined up
your Button is limiting the height, so either you could make layout_hieght of button to match-parent or if that looks odd, put the button in linearlayout and make the new linearlayout's height as match_parent
But I think the best way would be using a RelativeLayout and having all 3 views in the same layout

Resources