When I click the add button to add a new view, everything but images are displaying on the screen. I tried different images in different positions. But nothing worked.
public void onClick(View view) {
LayoutInflater vi = null;
vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = vi.inflate(R.layout.news_views, null);
ViewGroup insertPoint = (ViewGroup) findViewById(R.id.allNews);
insertPoint.addView(v, 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
}
This is the method I am using and news_views is the layout I am using to add a new news on the main screen.
To show that it is actually there I added a background color.
And also when there is no background it makes space, so it is there but not really :/
This is the .xml file of the news_views:
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/news_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/grey_round"
android:padding="15dp">
<TextView
android:id="@+id/textView"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:text="Heading Is Just Right Here"
android:textColor="#FFFFFF"
android:textSize="24sp" />
<TextView
android:id="@+id/textView2"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_row="1"
android:layout_column="0"
android:text="This is going to be a preview for the user to understand what is about this article."
android:textColor="#FFFFFF"
android:textSize="18sp" />
<ImageView
android:id="@+id/upvoteIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_row="2"
android:layout_column="2"
app:srcCompat="@android:drawable/arrow_up_float" />