RelativeLayout get out of adjust by inflating - android

In this piece of code I tried to set background for my relative layout, then I added a text view to the layout(in center of it), but when I run the application the text is not centered!
here is the java code:
RelativeLayout mainLayout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
createMainLayout();
LayoutInflater inflater = getLayoutInflater();
RelativeLayout list = (RelativeLayout)inflater.inflate(R.layout.activity_main
, null, false);
mainLayout.addView(list);
setContentView(mainLayout);
}
public void createMainLayout()
{
Bitmap bm = BitmapFactory.decodeResource(getResources(),
R.drawable.background_pattern);
BitmapDrawable drawable = new BitmapDrawable(getResources(), bm);
drawable.setTileModeXY(android.graphics.Shader.TileMode.REPEAT,
android.graphics.Shader.TileMode.REPEAT);
mainLayout = new RelativeLayout(this);
mainLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
mainLayout.setBackground(drawable);
}
and here is my activity_main:
<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"
tools:context="${relativePackage}.${activityClass}" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="140dp"
android:textSize="70sp"
android:text="#string/app_name" />
</RelativeLayout>
why is this happening? when I simply call setContentView(R.Layout.activity_main) beside setContentView(mainLayout) it displays correctly, but as expected there is no background for the layout.

Issue is here inflater.inflate(R.layout.activity_main, null);. When using this function to inflate, the root view is not being considered. Here is the workaround;
<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"
tools:context="${relativePackage}.${activityClass}" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="140dp"
android:textSize="70sp"
android:text="#string/app_name" />
</RelativeLayout>
</RelativeLayout>

Remove these lines from textview:
android:layout_alignParentTop="true"
android:layout_marginTop="140dp"

Try this...
<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"
tools:context="${relativePackage}.${activityClass}"
android:gravity="center" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="70sp"
android:text="#string/app_name" />
</RelativeLayout>

Related

Adding Views dynamically in Linear Layout in Fragment

I am trying to add TextView to the nested linearLayout in fragmentin onCreateView, I don't know if this is the correct approach or not, new to android!
Thanks in advance
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false);
List<LifeBerrysXmlParser.Item> items = (ArrayList<LifeBerrysXmlParser.Item>) getArguments().getSerializable("List");
TextView mainHeading = (TextView) rootView.findViewById(R.id.mainHeading);
ImageView mainImage = (ImageView) rootView.findViewById(R.id.articleMainImage);
LinearLayout articleLayout = (LinearLayout) rootView.findViewById(R.id.articleLayout);
TextView tev = new TextView(getActivity());
tev.setText("Hello..............");
articleLayout.addView(tev);
LifeBerrysXmlParser.Item item = items.get(getArguments().getInt("position"));
String articleMainHeading = item.mainHeading;
String articlemainImage = item.mainImage;
mainHeading.setText(articleMainHeading);
if (!articlemainImage.isEmpty()) {
Picasso.with(getContext()).load(articlemainImage).into(mainImage);
}
return rootView;
}
can anyone please help me what I am doing wrong?
here is my xml for the fragment
<?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:fillViewport="true"
android:id="#+id/content"
android:padding="1dp"
android:layout_weight="1"
android:background="#000000"
android:layout_gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff"
android:scrollIndicators="right">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/articleMainImage"
android:maxHeight="300dp"/>
<TextView
style="?android:textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightLarge"
android:layout_weight="1"
android:lineSpacingMultiplier="1.2"
android:id="#+id/mainHeading"
android:textColor="#ff6435"
android:clickable="false"
android:layout_gravity="center"
android:layout_centerInParent="true"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/articleLayout"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Read More"
android:textSize="15dp"
android:textStyle="bold"
android:layout_gravity="center"
android:clickable="true"
android:focusable="false"
android:gravity="center"
android:onClick="readMore"
android:padding="1dp"
android:textColor="#android:color/holo_green_light" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
You have mistake in your article layout. Your article layout has horizontal orientation, and it's child TextView has match_parent width, so when you add new child, it'll be outside the screen. Change orientation to vertical:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/articleLayout"
android:orientation="vertical"> <---- Change this line
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Read More"
android:textSize="15dp"
android:textStyle="bold"
android:layout_gravity="center"
android:clickable="true"
android:focusable="false"
android:gravity="center"
android:onClick="readMore"
android:padding="1dp"
android:textColor="#android:color/holo_green_light" />
</LinearLayout>

How to add image view and text view to a linear layout

my xml is like follow I want to add image view and text view programmatically to given xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="25dip" >
<TextView
android:id="#+text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="12dip"
android:text="#string/app_name"
android:textSize="24.5sp" />
</LinearLayout>
but I want output like following programmatically ie a linear layout contain image view and old text view and add that linearlayout below to new textview.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="25dip" >
<TextView
android:id="#+name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="12dip"
android:text="#string/app_name"
android:textSize="24.5sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="25dip" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginBottom="12dip"
android:src="#drawable/app_icon_big" />
<TextView
android:id="#+text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="12dip"
android:text="#string/app_name"
android:textSize="24.5sp" />
</LinearLayout>
</LinearLayout>
Try this way,hope this will help you to solve your problem.
main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/outerLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="25dp" >
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:text="#string/app_name"
android:textSize="24.5sp" />
</LinearLayout>
MainActivity.java
public class MyActivity extends Activity {
private LinearLayout outerLinearLayout;
private TextView text1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
outerLinearLayout = (LinearLayout) findViewById(R.id.outerLinearLayout);
text1 = (TextView) findViewById(R.id.text1);
LinearLayout innerLinearLayout = new LinearLayout(this);
ImageView imageView = new ImageView(this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
params.bottomMargin=12;
imageView.setLayoutParams(params);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setImageResource(R.drawable.ic_launcher);
innerLinearLayout.addView(imageView);
TextView textView = new TextView(this);
textView.setTextSize((float) 24.5);
textView.setText("New Text View");
textView.setLayoutParams(params);
outerLinearLayout.removeAllViews();
innerLinearLayout.addView(text1);
outerLinearLayout.addView(textView);
outerLinearLayout.addView(innerLinearLayout);
}
}
change inner layout
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="25dip" >
By
<LinearLayout
android:id="#+id/internal_image_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="25dip"
android:visibility="gone" >
Then whenEver you want to show just
findViewById(R.id.internal_image_textView).setVisibility(View.VISIBLE)

Add fragment as Subview in android

I have a fragment which has a horizontal scrollview. I want to add another fragment to this scrollview. How can I do that?
Here is my first fragment
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="220dp"
android:background="#drawable/arrow_bg">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/horizontalScrollView"
android:layout_marginTop="15dp" >
<LinearLayout
android:id="#+id/offerLayout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"></LinearLayout>
</HorizontalScrollView>
</LinearLayout>
I am trying to add the below fragment to the scrollview
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="174dp"
android:layout_height="214dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="HEALTH"
android:id="#+id/offerTitle"
android:capitalize="characters" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/offer_image_text_bg">
<ImageView
android:layout_width="wrap_content"
android:layout_height="135dp"
android:id="#+id/offerIcon"
android:src="#drawable/health_img"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/favLayout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ratingBar"
android:numStars="5"
android:rating="4"
android:isIndicator="true"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
style="#style/ratingBarStyle"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:id="#+id/favIcon"
android:src="#drawable/like_icon"
android:layout_alignParentRight="true"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_below="#+id/favLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/txt_OfferTitle2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="#+id/txt_OfferDesc" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
This is the code I am using for the same
private void loadSelectedOffers() {
for(int i=0;i<3;i++)
{
OfferItemFragment offerItem = new OfferItemFragment();
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
offerItem.getView().setLayoutParams(params);
offerLayout.addView(offerItem.getView());
}
}
But I am getting a null pointer exception at line
offerItem.getView()
How can I do this properly?
Add a FrameLayout to your first fragment and then add the fragment to that framelayout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/parent"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="220dp"
android:background="#468494">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/horizontalScrollView"
android:background="#BB099D"
android:layout_marginTop="15dp" >
<LinearLayout
android:id="#+id/child"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black">
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
Then in your code add the fragment to the view using FragmentManager and FragmentTransaction
public class MainActivity extends Activity {
Fragment f;
EditText send;
LinearLayout parent;
LinearLayout child;
HorizontalScrollView scroll;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
ViewGroup vg = (LinearLayout) inflater.inflate(R.layout.activity_main, null );
child = (LinearLayout) vg.findViewById(R.id.child);
loadSelectedOffers();
setContentView(vg);
}
private void loadSelectedOffers() {
for(int i=0;i<3;i++)
{
FrameLayout frame = new FrameLayout(this);
child.addView(frame);
frame.setId(i);
frame.setBackgroundColor(getResources().getColor(R.color.black));
frame.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
SenderFragment offerItem = new SenderFragment();
transaction.add(i, offerItem, "offer_item_" );
transaction.commit();
}
}
I believe something like this should work now.
You are getting view null because its onCreateView() has not been executed yet, that in turn is because you have merely instantiated the fragment and not attached it to your activity.
Try adding FrameLayouts in your HSV and replacing them by the fragments.

Dynamically change the margins of RelativeLayout which is getting inflated via xml

I am tryin to add ten relativeLayouts dynamically by inflating the xml , but the relative layouts getting overlapped. how to change the margins of the inflating xml dynamically via code.
Below is the code reuse.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/aaa"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
>
<ImageView
android:id="#+id/image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="5dp"
android:scaleType="centerCrop"
android:src="#drawable/ballaya" />
<TextView
android:id="#+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="50dp"
android:layout_marginTop="12dp"
android:layout_weight="1"
android:text="Srimannarayana earns Rs 8.65 cr on day 1"
android:textColor="#FFFFFF"
android:textSize="11sp"
android:textStyle="bold" />
<View
android:id="#+id/seperator"
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:layout_below="#+id/image"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="#FFFFFF" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:src="#drawable/popover_bg_rghtarw" />
</RelativeLayout>
code of item.xml
<?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"
android:background="#06516E" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="20dp"
android:background="#49C7F9">
<TextView
android:id="#+id/HeadLines"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Latest News"
android:textColor="#FFFFFF"
android:textSize="12sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/newsLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="30dp" >
</RelativeLayout>
</RelativeLayout>
Java Code
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.item);
newsLayout =(RelativeLayout)findViewById(R.id.newsLayout);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout row[] = new RelativeLayout[10];
TextView text[]= new TextView[10];
for(int i=0;i<10;i++){
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
row[i] = (RelativeLayout) inflater.inflate(R.layout.reuse,null);
params.setMargins(0, 50, 0, 0);
newsLayout.addView(row[i],params);
text[i]= (TextView) row[i].findViewById(R.id.text);
text[i].setText("AAAAAAA");
}
You can use LinearLayout instead of RelativeLayout for newsLayout and make the orientation as VERTICAL.
And instead of newsLayout =(RelativeLayout)findViewById(R.id.newsLayout);
write: newsLayout =(LinearLayout)findViewById(R.id.newsLayout);
And rest of the code will be as it is.
This will solve your problem.

Android: Custom view from xml layout

i would like to create a custom View (subclass of the View class) and use a layout xml resource.
I want something like this:
public class CustomView extends LinearLayout {
public CustomView(Context context) {
super(context);
LayoutInflater mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mInflater.inflate(R.layout.tweet, this, true);
}
This actually creates a View with the right height and width (a ScrollView with a list of those has exactly the expected length and scrollbars) but they are empty (black) even though the xml layout contains a lot of TextViews.
This is my xml layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tweet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:background="#ffffff">
<TextView
android:text="User"
android:id="#+id/tvusername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textStyle="bold">
</TextView>
<View
android:layout_width="5dip"
android:layout_height="1dip">
</View>
<TextView
android:text="userscreenname"
android:id="#+id/tvuserscreenname"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
<TextView
android:text="0s"
android:id="#+id/tvtime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
</TextView>
</RelativeLayout>
<TextView
android:text="Tweet Content"
android:id="#+id/tvcontent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000">
</TextView>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#ffffff">
</View>
<TextView
android:text="Retweet by"
android:id="#+id/tvrtby"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
This is my main layout:
<?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:background="#ffffff"
>
<ScrollView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="#+id/scrollView1"
android:orientation="vertical"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="match_parent"
android:id="#+id/timeline"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ffffff">
<TextView
android:id="#+id/tvoutput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/hello"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
This is how I add the custom view to my main view:
Not working (what I try to achieve):
TweetView ctweet = new TweetView(getApplicationContext(),tweet);
timeline.addView(ctweet);
My current solution (works, but uses no custom view):
View vtweet = View.inflate(getApplicationContext(), R.layout.tweet,null);
TextView tvusername = (TextView) vtweet.findViewById(R.id.tvusername);
TextView tvuserscreenname = (TextView) vtweet.findViewById(R.id.tvuserscreenname);
TextView tvcontent = (TextView) vtweet.findViewById(R.id.tvcontent);
TextView tvtime = (TextView) vtweet.findViewById(R.id.tvtime);
tvusername.setText(tweet.getUser().getName());
tvuserscreenname.setText('#' + tweet.getUser().getScreenName());
tvcontent.setText(tweet.getText());
//tvtime.setText(ctweet.tvtime.getText());
timeline.addView(vtweet);
you can use this in your xml just like any other view like <TextView
try <packageName.ClassName ie something like <com.example.CustomView
Probably you have to set the Layout Params of your TweetView object.
LinearLayout.LayoutParams fieldparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f);
ctweet.setLayoutParams(fieldparams);

Categories

Resources