GridView에 LinearLayout을 추가하려고하는데 문제가 있습니다. 기본적으로 나는 그 아래에 이미지가있는 일련의 아이콘을 만들려고합니다. (Launcher.app과 마찬가지로)GridView에 선형 레이아웃을 추가하면 각 요소가 전체 행으로 생성됩니다.
내가보고있는 것은 GridView가 표시되면 작은 아이콘으로 분리되지 않습니다. 대신 모든 아이콘이 자체 행에 표시됩니다.
이내 어댑터가 :
이@Override public View getView(int position, View convertView, ViewGroup parent) {
LinearLayout llView;
ImageView imageView;
TextView textView;
if (convertView == null) { // if it's not recycled, initialize some attributes
LayoutInflater inflater = FolderSelectionActivity.this.getLayoutInflater();
llView = (LinearLayout) inflater.inflate(R.layout.folder_view, null);
} else {
llView = (LinearLayout) convertView;
}
imageView = (ImageView) llView.findViewById(R.id.folder_image_view);
textView = (TextView) llView.findViewById(R.id.folder_text_view);
imageView.setImageBitmap(mDrive.getPreview(mFiles.get(position)));
textView.setText(mFiles.get(position).getTitle());
return llView;
내보기의 XML :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#FF0000FF"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView android:id="@+id/folder_image_view"
android:scaleType="centerCrop"
android:background="#FFFF0000"
android:layout_width="100px"
android:layout_height="100px"/>
<TextView android:id="@+id/folder_text_view"
android:background="#FF00FF00"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
그리고 마지막으로는, 내 작업의 레이아웃 :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<GridView android:id="@+id/folder_grid_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</RelativeLayout>
내가 해봤 관련 파일 및 코드 아래에 LinearLayout에 모든 종류의 비틀기가 있지만 작동하는 것을 찾을 수없는 것 같습니다. 누구든지 여기서 무엇을 해야할지 알고 있습니까?
편집 :
imgur 스크린 샷 : http://imgur.com/PsSvW
가장 좋은 방법을 사용하여
ViewGroup parent
에 별도로TextView
및ImageView
을 구성하고 추가 시도 할 수 있습니다. 안드로이드는 당신이'dp '를 사용할 것을 추천했다. –물론 있지만 도움이되지 않습니다. :) – jfaller
출력 스크린 샷을 붙여 넣을 수 있습니까? –