Android layout_width 및 layout_height에는보기의 내용과 패딩 만 포함되어있는 것으로 보입니다. 그렇다면 왜 다음 코드가 작동합니까?android : layout_width 및 layout_height는 무엇을 의미합니까? 마진이 포함되어 있습니까?
나는이 경우에해야 할 일이 무엇인지 이해하지만, 왜 작동하는지 이해하지 못합니다. this post을 읽었습니다.
나는 링크 된 예제와 비슷한 코드로 RecyclerView를 사용하고 있습니다. RecyclerView의 각 항목
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="match_parent "
android:layout_height="200dp"
card_view:cardCornerRadius="4dp"
android:padding="40dp"
android:layout_margin="24dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.CardContent">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="@+id/my_text_view"
android:text="fub"
android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Lorem ipsum dolor sit amet"/>
</LinearLayout>
및 카드보기에서 내 코드
@Override
public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_view, parent, false);
ViewHolder vh = new ViewHolder(v);
return vh;
}
특정 레이아웃 질문에 대해 잘 모르겠지만 'layout_width' 및'layout_height '는 일반적으로 내용 + 패딩을 나타내지 만 여백은 참조하지 않습니다. 여백은보기 외부에서 고려됩니다. –