1. 程式人生 > >在listview的item中寫上一個類似於商品數量的加減的控制元件

在listview的item中寫上一個類似於商品數量的加減的控制元件

這裡的程式碼比較重要的是紅色部分的LinearLayout的佈局。重要的是LinearLayout 中的文字不能再水平上和垂直上居中的問題。在此紀錄這個問題。

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="5dp" >


    <ImageView
        android:id="@+id/img_gouwu_select"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_centerVertical="true"
        android:scaleType="fitXY"
        android:src="@drawable/shouhuo_xuanzhong" />


    <ImageView
        android:id="@+id/img_show"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_centerVertical="true"
        android:layout_marginLeft="5dp"
        android:layout_toRightOf="@id/img_gouwu_select"
        android:src="@drawable/ic_launcher" />


    <TextView
        android:id="@+id/tv_gouwuitem_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/img_show"
        android:text="嘉實多磁電磁爐電磁爐電磁爐嘉實多磁電磁爐電磁爐電磁電磁爐" />


   
      <LinearLayout
        android:id="@+id/linear_jia_jian"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_below="@id/tv_gouwuitem_name"
        android:layout_toRightOf="@id/img_show"
        android:layout_alignBottom="@id/img_show"
        android:background="@drawable/shape_rec_ccc"
        android:orientation="horizontal" >


        <TextView
            android:id="@+id/tv_gouwujian"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:layout_weight="1"
            android:text="-" />


        <View
            android:id="@+id/view_1"
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#ccc" />
         <TextView
            android:id="@+id/tv_gouwu_number"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:layout_weight="1"
            android:text="1" />
         <View
            android:id="@+id/view_2"
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:background="#ccc" />


        <TextView
            android:id="@+id/tv_gouwujia"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:gravity="center"
            android:layout_weight="1"
            android:text="+" />
        
        
        
    </LinearLayout>
    

    <TextView 
        android:id="@+id/tv_xiaoji"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="小計168.00"
        android:layout_alignBottom="@id/linear_jia_jian"
        android:layout_toRightOf="@id/linear_jia_jian"
        android:layout_marginLeft="5dp"
        android:gravity="center"
        />
     <TextView 
        android:id="@+id/tv_money"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="¥168.00"
        android:layout_alignParentRight="true"
        android:layout_marginRight="5dp"
        android:textColor="#E99941"
        android:layout_alignBottom="@id/linear_jia_jian"
        android:gravity="center"
        />
    


</RelativeLayout>

相關推薦

在listview的item一個類似商品數量控制元件

這裡的程式碼比較重要的是紅色部分的LinearLayout的佈局。重要的是LinearLayout 中的文字不能再水平上和垂直上居中的問題。在此紀錄這個問題。 <?xml version="1.0" encoding="utf-8"?> <Relative

一位從vb系轉到JAVA的朋友在一個一個類似VBMSGBOX的方法

fin return gen interface man text string listener com //此方法放一個自定義的JAVA類中 public static boolean msgBoxPlus(Activity objPage, String strTi

商城購物車控制元件的簡單封裝(續),解決ListView資料錯亂的問題

在上一篇文章中,我們學習了商城購物車加減控制元件的簡單封裝,知道了封裝的思路過程和使用方法。還沒有看過上一篇文章的朋友,建議先去閱讀 商城購物車加減控制元件的簡單封裝 。這段時間收到一些小夥伴的反饋,在ListView或者是RecyclerView中存在ite

jquery快速實現商品數量的方法

<!-- 快速實現數量加減 --> <!DOCTYPE html> <html> <head> <meta charset="utf-8">

微信小程式-template使用:實現購物車商品數量功能

前言上一篇我們實現了購物車功能,裡面有用到template模板功能來實現購物車商品數量加減和價格計算功能,可能篇幅過長介紹的並不清楚,本篇將詳細介紹一下template模板來減少冗餘程式碼。模板WXML提供模板(template),可以在模板中定義程式碼片段,然後在不同的地方

leetcode676+修改一個字母在vector的dict有沒有,類似字典樹,暴力

https://leetcode.com/problems/implement-magic-dictionary/description/ class MagicDictionary { public: set<string> s; /** Initialize

Mac Iterm2 配置類似 SecureCRT 的克隆對話 (clone session) 功能

在 Mac 上終端使用 iterm2,登入公司伺服器跳板機再登伺服器時,每次都要輸入密碼,以下方案實現類似於secureCRT一樣的session clone功能,每天只要登入一次跳板機就可以。

javascript : 一個類似 jquery css() 的方法

asc position sele create posit reat abs document one 我們知道,jquery css() 方法可以很方便的更改DOM的樣式。 但從原理上,這個並不復雜,我們完全可以自己寫一個。 上代碼。 updateDOMSty

自己在項目一個Jquery插件和Jquery tab 功能

分享 temp parameter turn sel url position pac tco 後臺查詢結果 PDFSearchResult實體類: [DataContract(Name = "PDFSearchResult")] public class P

vs2013/2015scanf函數類似error C4996: 'scanf': This function or variable may be unsafe的安全檢查錯誤

span 調試 ria 安全性 init 點擊 scan online pan   在使用vs2015時,遇到了scnaf函數安全性的問題,程序不能正常運行,錯誤如下: error C4996: ‘scanf‘: This function or variable may

原生封裝一個類似JQ的ajax方法

post ready else thead ret 封裝 har state class function $ajax(json){ //初始化參數 if(!json){ return; } json.type = json

在vue-cli一個數量

vue實現汽車購票的加減 需求:最少減到1,減到1時顏色變灰並且不讓再減,最大加到5,顏色變灰並且不再讓加,效果如下: html程式碼: <template> <div> <div class="zk-order"

shell腳本判斷一個命令是否執行成功

表示 tab 大於等於 fail code ucc 例如 p s 命令執行 2018-12-21 shell中使用符號“$?”來顯示上一條命令執行的返回值,如果為0則代表執行成功,其他表示失敗。結合if-else語句實現判斷上一個命令是否執行成功 示例如下: if

簡單問題:VIM 查詢 “一個” 的快捷鍵是什麼?

/pattern 向下搜尋 n繼續搜尋下一個 ?pattern 向上搜尋 #繼續搜尋上一個 1. 暫時顯示/取消行號: 使用Vim開啟檔案後,在Normal模式下輸入 :set number(或 :set nu)顯示行號 :set nonumber (或 :set nonu)取消行號 2. 永

java實現List集合獲取一個一個元素

public static void main(String[] args) { List<Integer> list = new ArrayList<Integer>(); list.add(1); list.add(2); lis

微信小程式開發常用技巧(7)——實現一個類似Android toast效果動畫

很多時候,我們在小程式中使用wx.showToast(),發現樣式不是很好看,那麼我們能不能做一個跟原生APP類似的toast呢?答案是肯定的。今天就利用微信小程式的動畫wx.createAnimation()實現一個簡單的類似原生APP的toast提示。 先

推薦一個類似國內知乎國外網站-Quora

好像是在知乎上隨意瀏覽時中看到Quora這個社群的,模糊的記得知主當時給的評價是Quora上有很多大咖,職業遍佈各個領域,對一些問題的看法比較新穎,還可以這麼說,足不出戶就可以感受到貼切的英語環境。抱著

用.NET Core實現一個類似餓了嗎的簡易拆紅包功能

  需求說明 以前很討厭點外賣的我,最近中午經常點外賣,因為確實很方便,提前點好餐,算準時間,就可以在下班的時候吃上飯,然後省下的那些時間就可以在中午的時候多休息一下了。 點餐結束後,會有一個好友分享紅包功能,雖說這個紅包不能提現,但卻可以抵扣點餐費用,對於經常點餐的人來說,直接用於抵扣現金確

ThinkPHP類似RBAC的權限控制

參與 一個數 前臺 序列 進行 名稱 cot 數據 stat admin最高權限的用戶只有一個,他將不參與判斷,直接顯示全部效果,商家管理權限,只單單顯示商家管理導航,其他隱藏或移除元素1、首先我們程序做完之後,進我們的model和controller裏面的方法進行數據庫的