Can you explain me please why my TextView don't work on gravity to left .
A: LinearLayout | orientation=HORIZONTAL | gravity A = top or center or bottom.
B: LinearLayout | orientation=VERTICAL | gravity B = left or center or right.
C: TextView
i us:
A.setGravity(gravity A);
B.setGravity(gravity B);
Result gravity:
top | left :not work (=top center)
center | left :not work (=center center)
bottom | left :not work (=bottom center)
top | center :work
center | center :work
bottom | center :work
top | right :work
center | right :work
bottom | right :work
LinearLayout parent = new LinearLayout(mContext); LinearLayout framelayoutTitle = new LinearLayout(mContext); framelayoutTitle.setOrientation(LinearLayout.HORIZONTAL); framelayoutTitle.setGravity(vGravityTitle); LinearLayout layoutTitle = new LinearLayout(mContext); layoutTitle.setOrientation(LinearLayout.VERTICAL); layoutTitle.setGravity(hGravityTitle); holder.textTitle = new TextView(mContext); layoutTitle.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); framelayoutTitle.setLayoutParams(new LinearLayout.LayoutParams((widthTitle * (width - dp2px(widthImageLV))) / 100, dp2px(heightTitle))); holder.textTitle.setText(titleList.get(position)); holder.textTitle.setGravity(alignmentTextTitle); holder.textTitle.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); holder.textTitle.setTextSize(sizeTitle); holder.textTitle.setBackgroundColor(Color.WHITE); layoutTitle.addView(holder.textTitle); framelayoutTitle.addView(layoutTitle); parent.setOrientation(LinearLayout.HORIZONTAL); parent.setGravity(Gravity.TOP); parent.addView(framelayoutTitle);