在Android中,假设我有一个[Serializable]
public class Player
{
public string playerId;
public string playerLoc;
public string playerNick;
}
...
void MyMethod(string s)
{
Player player = JsonUtility.FromJson<Player>(s);
Debug.Log(player.playerLoc);
}
,带有一个以RecyclerView
表示的单元格列表,我的问题是,如何在此上添加左边距和右边距整个RecyclerView 本身,以便每个单元还具有左右边距?与在单元格类中进行比较相比,我想有一种更好的方法,所以我想知道是否可以向LinearLayout
本身添加左右边距?
答案 0 :(得分:0)
在布局的xml文件中,只需向RecyclerView本身添加边距。
<RecyclerView
marginStart = "20dp"
marginEnd = "20dp"
/>