There Fragment
. Is it RecyclerView
attached below. The bottom line is that by design is the first element should take a little more space than the others. His I increase in ViewHolder
of the adapter when rendering as follows:
public class myAdapter extends RecyclerView.Adapter ...
...
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
WeatherForDay weather = mWeathersList.get(position);
holder.mDayTextView.setText(weather.getDay());
//todo update iconManager
//need icon manager, with input -> String, output ->(R.drawable.icon) int
holder.mIconImageView.setImageResource(R.drawable.testicon1);
holder.mTempTextView.setText(weather.getTmp());
if (position == 0) {
if (isFirstBind) {
Log.d(DEBUG_TAG, "is first bind and first position");
holder.setBig();
isFirstBind = false;
}
}
}
...
public void setBig() {
LinearLayout.LayoutParams param = (LinearLayout.LayoutParams) mRoundLayout.getLayoutParams();
int newHeight = (int) (param.height * 1.2f);
int newWidth = (int) (param.height * 1.2f);
param.height = newHeight;
param.width = newWidth;
mRoundLayout.setLayoutParams(param);
mRoundLayout.setBackgroundDrawable(createBigShape(newHeight));
}
private Drawable createBigShape(int newHW) {
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.RECTANGLE);
shape.setCornerRadii(new float[]{newHW, newHW, newHW, newHW, newHW, newHW, newHW, newHW});
shape.setColor(mContext.getResources().getColor(R.color.weryDark));
shape.setStroke(1, mContext.getResources().getColor(R.color.weryDark));
return shape;
}
...
}
How to make elements are aligned along the upper edge and the lower?
P.S. The same problem arises in that the N-element also somehow rendered "large" (on the same device with a large screen N = 13, on the small screen N = 8)
P.S.2 Can eat what is more optimal way to change any element RecyclerView
?
item_recycler.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/day_text_view_list_item_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/colorWhite"
android:background="@null"/>
<LinearLayout
android:id="@+id/rounded_linear_layout"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/round_shape"
android:gravity="center_horizontal"
android:orientation="vertical">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/icon_image_view_list_item_bottom"
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@null"
app:srcCompat="@drawable/testicon1"
tools:ignore="MissingPrefix"/>
<TextView
android:id="@+id/temperature_text_view_list_item_bottom"
android:textColor="@color/colorWhite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>