Textview를 조건에 맞을때마다 오른쪽으로 정렬을 하고 싶어 Textview 위에 LinearLayout을 만들어서 그 Linear의 gravity를 조건마다 RIGHT로 밑의 코드처럼 설정했는데 동작하지 않네요 ㅠㅠ 제가 잘못한건가요??
TextView chatText =(TextView) v.findViewById(R.id.TextView_msg);
LinearLayout linear = (LinearLayout) v.findViewById(R.id.linear);
LinearLayout.LayoutParams lparam =
        (LinearLayout.LayoutParams)linear.getLayoutParams();
lparam.gravity = Gravity.RIGHT;
linear.setLayoutParams(lparam);<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <!-- A CardView that contains a TextView -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/linear"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="17sp"
            android:paddingLeft="15dp"
            android:background="@drawable/chat_text"
            android:paddingRight="15dp"
            android:paddingTop="8dp"
            android:textColor="#000000"
            android:paddingBottom="8dp"
            android:id="@+id/TextView_msg"
            />
    </LinearLayout>
</LinearLayout>