我是Android开发的新手.我正在尝试使用RecyclerView在屏幕上一次只显示一张卡片显示一张卡片列表.但遗憾的是,我设计的卡片并未按预期填充整个屏幕宽度,如下图所示.如何拉伸这些卡片以填充整个屏幕(宽度方面,高度是包装内容).有没有解决这个问题的方法?
我的代码:
activity_sub.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/appBar"
layout="@layout/app_bar"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Horizontal Card List"
android:textSize="16sp"
android:padding="3dp"
android:background="#CCCCCC" />
<android.support.v7.widget.RecyclerView
android:id="@+id/hrlist_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
custom_card.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp"
android:tag="contains Cards main Container">
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="10dp"
app:cardBackgroundColor="#B6B6B6">
<TextView
android:id="@+id/card_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="20dp"
android:text="Card 1"
android:textSize="30sp" />
</android.support.v7.widget.CardView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
SubActivity.java
package ab9.mamv.com.playground;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBarActivity;
import …
Run Code Online (Sandbox Code Playgroud) 我最近开始使用Android Studio,我发现有一点不同(特别是)与Eclipse不同,Android Studio 在创建新应用程序时没有提供选择应用程序图标及其形状和大小的任何选项.在完成我的应用程序开发时,我尝试使用自己的图像更改默认的"ic_launcher.png",但我无法将其形状(默认情况下为方形)更改为圆形.
所以我的问题是 - 有没有办法改变Android Studio中的应用程序图标形状?如果这个问题已经在其他一些主题上得到解决,那么请与我分享这个链接.(PS-我试图在这里搜索类似的问题,但找不到可能的解决方案,因此我自己发布这个问题)