2017-09-29 4 views
1

보다이 스크린 샷은 산들 바람Cardview이 장치에서 제대로 작동하지 않는 낮은 롤리팝

enter image description here

이 하나가 이미지가 표시되지 않습니다에 젤리 콩에서 가져온 것입니다 촬영하고 메뉴의 텍스트입니다 하지

enter image description here

볼 나는 부모보기로 Cardview와 레이아웃을 가지고있다.

이미지와 텍스트로 구성됩니다.

: 이제 레이아웃은 이미지 properly.They 작은 켜고 완전히 여기

의 내 레이아웃 XML 파일을 카드보기를 일치하지 않습니다 표시되지 않습니다 안드로이드 M과 이상 장치에 있지만 (젤리 빈 등) 낮은 버전에서 잘 작동

<android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="3dp" 
      app:cardPreventCornerOverlap="false" 
      android:elevation="2dp"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center_vertical" 
       android:orientation="horizontal"> 

       <android.support.v7.widget.CardView 
        android:layout_width="80dp" 
        android:layout_height="80dp"> 

        <ImageView 
         android:id="@+id/home_news_image" 
         android:layout_width="80dp" 
         android:layout_height="80dp" 
         android:layout_gravity="center_vertical" 
         android:scaleType="centerCrop" 
         android:src="@drawable/jesus" /> 
       </android.support.v7.widget.CardView> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="5dp" 
        android:gravity="center_vertical" 
        android:orientation="vertical"> 

        <TextView 
         android:id="@+id/home_title_parish_news" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="5dp" 
         android:paddingLeft="1dp" 
         android:text="Christmas Celebration" 
         android:textSize="14dp" 
         android:textStyle="bold" /> 

        <TextView 
         android:id="@+id/home_short_description" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:ellipsize="end" 
         android:maxLines="1" 
         android:padding="3dp" 
         android:text="hi this is to tell thlkdsa asdsag slk sg sdg sdgjs gsd gsg jglsgja gasjggjasg asgjasgj sgjasg g g" 
         android:textSize="12dp" /> 

        <TextView 
         android:id="@+id/home_date_published" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginRight="10dp" 
         android:gravity="right|bottom" 
         android:padding="3dp" 
         android:text="10/10/2010" 
         android:textSize="8dp" /> 
       </LinearLayout> 
      </LinearLayout> 
     </android.support.v7.widget.CardView> 

이 내가 텍스트가 표시되지 않는 이미지에서 텍스트를 배치하면 난 내 레이아웃 및 뷰 또한

public class MenuAdapter extends BaseAdapter { 

    Context mContext; 
    ArrayList<MenuModel> list; 
    String img; 


    public MenuAdapter(Context c, ArrayList<MenuModel> list) { 
     mContext = c; 
     this.list = list; 

    } 

    @Override 
    public int getCount() { 
     return list.size(); 
    } 

    @Override 
    public Object getItem(int i) { 
     return i; 
    } 

    @Override 
    public long getItemId(int i) { 
     return i; 
    } 

    @Override 
    public View getView(int i, View view, ViewGroup viewGroup) { 
     View grid; 
     LayoutInflater inflater = (LayoutInflater) mContext 
       .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     if (view == null) { 
      grid = inflater.inflate(R.layout.home_grid_menu, null); 
      TextView textView = (TextView) grid.findViewById(R.id.home_grid_text); 
      ImageView imageView = (ImageView) grid.findViewById(R.id.home_grid_image); 
      textView.setText(list.get(i).getMenuName()); 
      imageView.setImageResource(list.get(i).getMenuImage()); 

     } else { 
      grid = (View) view; 
     } 

     return grid; 
    } 
} 

를 초기화 어댑터입니다.

제발 어떻게 가야할지 제안 해주세요.

나는 그들이 뒤로 지원을하지만, 렌더링은 일반적으로 동일하지 않습니다, 내가

+0

이 두 이미지를 첨부 안드로이드 의도를 사용하여 텍스트를 공유 할 수 있습니다. –

+0

framelayout에서 cardview를 래핑 해보세요 (선형보기와 카드보기 사이에 추가). – Jimmy

+0

레이아웃을 초기화하는 코드는 어디에 있습니까? – DeKaNszn

답변

0

카드 뷰가 제대로 롤리팝을 시작하는 작품 몇 가지 솔루션을 얻을 것이다 해주기를 바란다. 두 화면

1

먼저 여기에 안드로이드에서 자산 폴더에서 파일을 읽을 필요의 이미지를 첨부 해주세요 특정 문제에 대한

자산 폴더에서 HTML 파일을 읽을 수있는 방법을 예입니다

InoutInputStream is = getAssets().open("yourfile.html"); 
int size = is.available(); 

byte[] buffer = new byte[size]; 
is.read(buffer); 
is.close(); 
String str = new String(buffer); 

HTML 파일에서 HTML.fromhtml을 사용하여 텍스트를 가져와야하는 문자열에 html 파일이 있습니다. 당신이 HTML 텍스트를 공유하려는 경우

String htmltext=Html.fromHtml(Html.fromHtml(str).toString()) 

는 당신은

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); 
    sharingIntent.setType("text/plain"); 
    sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Sharing html Text"); 
    sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, htmltext); 
    startActivity(Intent.createChooser(sharingIntent, "Select")); 
+0

에 대한 질문을 참조하십시오 내가 코드 부분에서 내 의견을 초기화 어댑터 클래스를 추가 한 답변 해 주셔서 감사합니다. – DeKaNszn

+0

열기에 대한 아니다 상단 – Jeyaseelan